E - Weighted Tic-Tac-Toe Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 450

問題文

3 \times 3 のマス目があります。上から i 行目、左から j 列目 (1 \leq i,j \leq 3) のマスをマス (i,j) と表します。マス (i,j) には整数 A_{i,j} が書かれています。ここで、 \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} は奇数であることが保証されます。また、すべてのマスははじめ白で塗られています。

高橋君と青木君が、このマス目を使ってゲームを行います。ゲームでは、高橋君を先手として、二人が交互に以下の操作を行います。

  • 白で塗られているマス (i,j)\,(1\leq i,j \leq 3) を選ぶ(操作が行われる時点で、そのようなマスは必ず存在することが示せる)。操作をしているプレイヤーが得点 A_{i,j} を得る。次に、操作をしているプレイヤーが高橋君ならば、マス (i,j) を赤で、青木君ならば青で塗る。

各操作のあと、次の判定を行います。

  • 赤または青の同じ色で塗られたマスが縦・横・斜めのいずれかの方向に 3 つ連続する箇所があるか判定する。そのような箇所があれば、その時点でゲームを終了し、赤が 3 つ連続しているならば高橋君が、青が 3 つ連続しているならば青木君が勝利する。
  • 白で塗られているマスが存在するか判定する。存在しなければ、その時点でゲームを終了し、その時点までに獲得した累計の得点が高い方のプレイヤーが勝利する。

ゲームは必ず有限回の操作で終了し、高橋君または青木君の一方が勝利することが示せます。両者が勝ちを目指して最適に行動するとき、どちらが勝つか判定してください。

制約

  • |A_{i,j}| \leq 10^9
  • \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} は奇数
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

A_{1,1} A_{1,2} A_{1,3}
A_{2,1} A_{2,2} A_{2,3}
A_{3,1} A_{3,2} A_{3,3}

出力

高橋君が勝つならば Takahashi を、青木君が勝つならば Aoki を出力せよ。


入力例 1

0 0 0
0 1 0
0 0 0

出力例 1

Takahashi

高橋君が最初の手番で (2,2) を選択すると、その後どのように青木君が行動しても、高橋君が適切に行動することで、青で塗られたマスが 3 つ連続しないようにすることができます。赤で塗られたマスが 3 つ連続した場合は高橋君が勝ちます。赤で塗られたマスが 3 つ連続せずにゲームが終了した場合、その時点で高橋君は 1 点、青木君は 0 点を獲得しているため、どちらにせよ高橋君が勝ちます。


入力例 2

-1 1 0
-4 -2 -5
-4 -1 -5

出力例 2

Aoki

Score: 450 points

Problem Statement

There is a 3 \times 3 grid. Let (i, j) denote the cell at the i-th row from the top and j-th column from the left (1 \leq i, j \leq 3). Cell (i, j) contains an integer A_{i,j}. It is guaranteed that \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} is odd. Additionally, all cells are initially painted white.

Takahashi and Aoki will play a game using this grid. Takahashi goes first, and they take turns performing the following operation:

  • Choose a cell (i, j) (1\leq i, j \leq 3) that is still painted white (it can be shown that such a cell always exists at the time of the operation). The player performing the operation scores A_{i,j} points. Then, if the player is Takahashi, he paints the cell (i, j) red; if the player is Aoki, he paints it blue.

After each operation, the following checks are made:

  • Check if there are three consecutive cells painted the same color (red or blue) in any row, column, or diagonal. If such a sequence exists, the game ends immediately, and the player whose color forms the sequence wins.
  • Check if there are white cells left. If no white cells remain, the game ends, and the player with the higher total score wins.

It can be shown that the game will always end after a finite number of moves, and either Takahashi or Aoki will win. Determine which player wins if both play optimally for victory.

Constraints

  • |A_{i,j}| \leq 10^9
  • \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} is odd.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

A_{1,1} A_{1,2} A_{1,3}
A_{2,1} A_{2,2} A_{2,3}
A_{3,1} A_{3,2} A_{3,3}

Output

If Takahashi wins, print Takahashi; if Aoki wins, print Aoki.


Sample Input 1

0 0 0
0 1 0
0 0 0

Sample Output 1

Takahashi

If Takahashi chooses cell (2,2) in his first move, no matter how Aoki plays afterward, Takahashi can always act to prevent three consecutive blue cells. If three consecutive red cells are formed, Takahashi wins. If the game ends without three consecutive red cells, at that point, Takahashi has scored 1 point and Aoki 0 points, so Takahashi wins either way.


Sample Input 2

-1 1 0
-4 -2 -5
-4 -1 -5

Sample Output 2

Aoki