Don't Split The Atom!
InterviewTime limit2sMemory limit512 MB
Two players alternately split a pile of atoms, and whoever is forced to split a single atom loses; decide the winner for each n.
- Level
Medium4 of 10
- Topics
- Game theory, Math, Greedy, Implementation
- Solved
- No attempts yet
Problem
Two mad (and evil) scientists, Professor Zoom and Doctor Horrible, have just obtained atoms of a very rare element, and they want to share them. They have decided to play the following game.
First, Professor Zoom divides the atoms into two non-empty groups. Next, Doctor Horrible takes one group for his evil purposes and splits the other group into two non-empty parts. Then Professor Zoom takes one of the parts and splits the other part into two, returning it to Doctor Horrible. The game continues this way: on every turn, one scientist takes one part and splits the other. Eventually one player is forced to split a single atom. This causes an explosion, and the unlucky splitter loses the game (probably along with his life).
Given the number of atoms , determine which of the two villains survives the game.

Input
The first line of input contains the number of test cases (). The descriptions of the test cases follow.
Every test case consists of one integer (), the initial number of atoms.
Output
For each test case output a line containing a single character: 'A' if Professor Zoom wins the game, 'B' if Doctor Horrible wins.