Hide

Problem B
Big Integers

Nick is preparing a problem for a programming contest about comparing big integers. He has decided on the input format for the integers: They will be expressed in base 62, with $0$ through $9$ representing digit values $0$ through $9$, lowercase letters a through z representing digit values $10$ through $35$, and uppercase letters A through Z representing digit values $36$ through $61$. For example, the string Aa would represent $36 \times 62 + 10 = 2242$.

The problem is to take two strings representing two distinct base 62 integers and determine which of the two is smaller. However, Nick wrote his judge solution incorrectly, assuming that the lexicographically smaller string is always the smaller integer.

Given some test cases, determine for each if Nick’s solution would report the correct result.

Input

The first line of input contains a single integer $t$ ($1\leq t \leq 10^5$). This is the number of test cases.

Each test case consists of two lines.

The first line contains a single alphanumeric string of length at most $10^5$.

The second line contains a single alphanumeric string of length at most $10^5$.

Both strings are guaranteed to contain no unnecessary leading zeroes, and the two strings are guaranteed to be distinct.

The sum of the lengths of all input strings across all $t$ test cases is guaranteed to be at most $2 \times 10^6$.

Output

For each test case, output a single line with YES if the lexicographically smaller string represents the smaller integer in base 62, and output a single line with NO otherwise.

Sample Input 1 Sample Output 1
2
icpc
ICPC
a
bc
NO
YES

Please log in to submit a solution to this problem

Log in