パナソニックプログラミングコンテスト(AtCoder Beginner Contest 195)
E
Lucky 7 Battle
AtCoder
⌀ 1609
原题
← DF →
翻译中…

Problem Statement

翻译中…

We have a string $S$ of length $N$ consisting of 0, $\ldots$, 9, and a string $X$ of length $N$ consisting of A and T. Additionally, there is a string $T$, which is initialized to an empty string.

翻译中…

Takahashi and Aoki will play a game using these. The game consists of $N$ rounds. In the $i$-th round $(1\leq i \leq N)$, the following happens:

翻译中…
  • If $X_i$ is A, Aoki does the operation below; if $X_i$ is T, Takahashi does it.
  • Operation: append $S_i$ or 0 at the end of $T$.
翻译中…

After $N$ operations, $T$ will be a string of length $N$ consisting of 0, $\ldots$, 9. If $T$ is a multiple of $7$ 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

翻译中…
  • $1 \leq N \leq 2\times 10^5$
  • $S$ and $X$ have a length of $N$ each.
  • $S$ consists of 0, $\ldots$, 9.
  • $X$ consists of A and T.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
S
X

翻译中…

Output

翻译中…

If Takahashi wins when the two players play optimally, print Takahashi; if Aoki wins, print Aoki.

翻译中…

样例

Input #1
2
35
AT
Output #1
Takahashi
In the $1$-st round, Aoki appends `3` or `0` at the end of $T$. In the $2$-nd round, Takahashi appends `5` or `0` at the end of $T$. If Aoki appends `3`, Takahashi can append `5` to make $T$ `35`, a multiple of $7$. If Aoki appends `0`, Takahashi can append `0` to make $T$ `00`, a multiple of $7$. Thus, Takahashi can always win.
Input #2
5
12345
AAAAT
Output #2
Aoki
Input #3
5
67890
TTTTA
Output #3
Takahashi
Input #4
5
12345
ATATA
Output #4
Aoki
题目信息
题号
abc195_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。