Problems
We want to build a string with English alphabet uppercase letters in sorted order. However, we want the order to be sometimes strictly increasing and sometimes strictly decreasing.
The first letter of the string must be A.
After that, the string must contain one or more blocks of letters.
The
For example, if there are A).
The strings XYZYBA, AZYCBA and AYZYBB are not valid
for this case because they violate the required starting letter condition, and the ordering
conditions in the first
and second block, respectively. The string AYZYBA is valid.
The string ABDCBA is also valid and, moreover, it is the alphabetically first valid
string.
Given the sizes of the blocks, output the valid string that comes first in alphabetical order in the list of all valid strings. It can be shown that, for all inputs within the given limits, at least one valid string exists.
Input
The first line of the input gives the number of test cases,
Output
For each test case, output one line containing Case #,
where
Example
3
2
2 3
2
5 1
1
2
Case #1: ABDCBA
Case #2: ABCDEFA
Case #3: ABC