You are given several distinct decimal digits. Choose a non-empty subset of these digits and arrange them in some order to form one integer. Arrange the remaining digits (which also form a non-empty set) in some order to form a second integer. Neither integer may begin with the digit 0, unless the integer is exactly 0.
For example, from the digits 0, 1, 2, 4, 6, and 7 you can form the pair of integers 10 and 2467. There are many such pairs: 210 and 764, 204 and 176, and so on. For the pair 204 and 176 the absolute difference is 28, and no pair formed under these rules achieves a smaller difference.
Find the smallest possible absolute difference between the two integers formed from the given digits.
The first line contains the number of test cases. Each test case is given on one line containing at least two and at most ten decimal digits (0 through 9). No digit appears more than once on a line, and the digits are listed in increasing order, separated by exactly one space.
For each test case, print on its own line the smallest absolute difference of the two integers that can be formed from the given digits under the rules above.