COMCB  Complete Chess Boards
BuggyD has always been fascinated with chess boards (though he really sucks at chess). He makes an observation that a chess board is complete with respect to knights and rooks and incomplete with respect to bishops (unless the dimensions are 1 × 1). A complete chess board is one in which it is possible to traverse all the squares starting from one possible square. Knights have always been his favourite pieces and he has decided to analyze completeness with respect to knights. Given the dimesions of the chess board help BuggyD find the lexicographically first path that visits all squares of a chess board with a knight.
Each square must be traversed only once. Note that a knight can only move two squares in one direction and one square perpendicular to the previous direction.
Input
The first line of the input contains an integer t, the number of test cases. t test cases follow.
Each test case consists of a single line cotaining two integers (X and Y) separated by a single space, specifying the dimensions of the chess board. The numbers 1 to X denote rows and the capital letters A to Y denote the coloumns. Each square is represented by its column index followed by it's row index  for example, B4 denotes the square in the 4th row and 2nd column.
The total number of squares on the chess board will be no more than 26.
Output
For each test case output one line consisting of the lexicographically first path of the knight, or "1" (quotes for clarity) if the chess board is incomplete with respect to a knight.
Example
Input: 1 4 5 Output: A1B3C1A2B4D3E1C2D4E2C3A4B2D1E3C4A3B1D2E4
hide comments
Luv Karakoti:
20140721 22:26:14
I am not able to comprehend the meaning of the phrase 'first lexicographical' path. Can please someone clarify this?


Legolas:
20140112 17:19:59
For


Krunal:
20110304 00:37:56
What if input is given as:


Krunal:
20110304 00:18:07
One Help: It is "Lexicographic order"

Added by:  Matthew Reeder 
Date:  20061029 
Time limit:  0.391s 
Source limit:  30000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  AlKhawarizm 2006 