Problem G
Optimus Prime
Input: standard input
Output: standard output
Time Limit: 30 seconds


Joe Uncool is a long-time fan of the online games "Ultima Online" and "Everquest". However, Joe has decided that they have become too watered down of late, and that they no longer satisfy his requirements for utter wastage of time.  He has invented a new game that he hopes will eliminate all productive activity from the entire world by 2010.  This game is rather predictably titled "Primes".  (Countless years of gaming have eroded Joe's creativity)


To play the game, an integer n is chosen, greater than 1.  A counter c is started at 0. The first player to play (let's call him player A) names a number from 1 to n, and this is added to c.  The other player (Player B) can then name a number from 1 to n, which is again added to c, and so on. The loser is the first person to make c nonprime. The winner is the first person to, er, not be the loser.  Note that 1 is NOT prime.


For example, a typical game (with n=5) played by very stupid people might Be:


  A: 3

  B: 2

  A: 5

Since 10 is not prime, B is now the winner.


A certain group, however, called the mathematicians, are achieving godlike status among their fellow humans by always being able to win the game.  Your job is to include yourself among their ranks, by solving the game's opening.



An integer G, where G is the number of games to be considered.  Following this are G integers, one to a line, containing the value of n for each game to be considered. (1<n<=1000)




With one game to a line, you are to print out who will win the game (A or B) assuming both play perfectly.  If it is A, you must also print out which number A must choose first to ensure his win.


Sample Input






Sample Output
A 3


A 7

A 157

(World Finals Warm-up Contest, Problem setter: Derek Kisman)


 “The point of the problem is NOT to optimize a few seconds here or there,
it's to prevent it from taking years or centuries. :)”