#R195E. [ABC195E] Lucky 7 Battle
[ABC195E] Lucky 7 Battle
Score : points
Problem Statement
We have a string of length consisting of 0, , 9, and a string of length consisting of A and T. Additionally, there is a string , which is initialized to an empty string.
Takahashi and Aoki will play a game using these. The game consists of rounds. In the -th round , the following happens:
- If is
A, Aoki does the operation below; if isT, Takahashi does it. - Operation: append or
0at the end of .
After operations, will be a string of length consisting of 0, , 9.
If is a multiple of as a base-ten number (after removing leading zeros), Takahashi wins; otherwise, Aoki wins.
Determine the winner of the game when the two players play optimally.
Constraints
- and have a length of each.
- consists of
0, ,9. - consists of
AandT.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi wins when the two players play optimally, print Takahashi; if Aoki wins, print Aoki.
2
35
AT
Takahashi
In the -st round, Aoki appends 3 or 0 at the end of . In the -nd round, Takahashi appends 5 or 0 at the end of .
If Aoki appends 3, Takahashi can append 5 to make 35, a multiple of .
If Aoki appends 0, Takahashi can append 0 to make 00, a multiple of .
Thus, Takahashi can always win.
5
12345
AAAAT
Aoki
5
67890
TTTTA
Takahashi
5
12345
ATATA
Aoki