Problem Description
There is a string containing only decimal digit characters. The length of the string is between 1 and 1,000. Using characters of the string, you have to construct the maximum number which divides by thirty-six without remainder. Each character of the string may not be used more than once.
Input
The first line of the input contains an integer T (T <= 1000), indicating the number of cases. Each case begins with a line containing a single line representing the source string.
Output
For each test case, print a line containing the test case number (beginning with 1) and the decimal representation of the maximum number (leading zeroes should be omitted). If no number can be constructed, please output “impossible” instead.
Sample Input
2
03061
345
Sample Output
Case 1: 6300
Case 2: impossible
Source
2010年全国大学生程序设计邀请赛(福州)