MCOINS  Coins Game
English  Vietnamese 
Asen and Boyan are playing the following game. They choose two different positive integers K and L, and start the game with a tower of N coins. Asen always plays first, Boyan – second, after that – Asen again, then Boyan, and so on. The boy in turn can take 1, K or L coins from the tower. The winner is the boy, who takes the last coin (or coins). After a long, long playing, Asen realizes that there are cases in which he could win, no matter how Boyan plays. And in all other cases Boyan being careful can win, no matter how Asen plays.
So, before the start of the game Asen is eager to know what game case they have. Write a program coins which help Asen to predict the game result for given K, L and N.
INPUT
The input describes m games.
The first line of the standard input contains the integers K, L and m, 1 < K < L < 10, 3 < m < 50. The second line contains m integers N1, N2, …, Nm, 1 ≤ Ni ≤ 1 000 000, i = 1, 2, …., m, representing the number of coins in each of the m towers
SAMPLE INPUT
2 3 5
3 12 113 25714 88888
OUTPUT
The standard output contains a string of length m composed of letters A and B. If Asen wins the ith game (no matter how the opponent plays), the ith letter of the string has to be A. When Boyan wins the ith game (no matter how Asen plays), the ith letter of the string has to be B.
SAMPLE OUTPUT
ABAAB
Problem for kid  Please, think like kid.
hide comments
rock7897:
20200211 14:14:48
just try to see if A can win otherwise B


sandeepd:
20191201 17:19:33
Nice problem, but output format cost me so many WAs :(


jackknowsit:
20191030 18:56:28
Stop this AC comments. It's ridiculous. Nobody finds it useful. 

adist98:
20190724 19:25:00
Interesting. 

amannegi227:
20190722 05:36:27
Easy Nice One :AC 

aj_254:
20190612 10:31:51
solvable in pypy .just optimize your code to last extent. 

harry_shit:
20190603 12:06:33
damnn!!! , that was beautifully easy. 

Rahul Kathuria:
20190321 05:00:12
damn easy dp :P 

exesharkx:
20190124 14:32:01
AC in one go 

manishjoshi394:
20181125 06:56:44
If you can't figure out what to do, try reading Topcoder tutorial on 'Algorithm games'. Here is the link, https://www.topcoder.com/community/competitiveprogramming/tutorials/algorithmgames/ 
Added by:  ~!(*(@*!@^& 
Date:  20090217 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  BOI For Kid 08 