QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#7970. Three-move Chess

統計

Description

K has an unwritten rule at home. If only K and H are home, they decide who cooks by playing a game called "Three-Step Chess." The rules of Three-Step Chess are somewhat similar to Gomoku. As is well known, Gomoku is a game where the first player to connect five of their own pieces wins. Similar to Gomoku, in Three-Step Chess, both players take turns placing pieces on a grid-based board and determine the winner based on whether a specified pattern is formed. Unlike Gomoku:

  1. Three-Step Chess does not distinguish between the pieces of the two players; that is, both players can be considered to be using pieces of the same color.
  2. When checking for the pattern, the specified pattern cannot be rotated.
  3. If the specified pattern is formed, the player who formed it wins if the total number of pieces on the board is a multiple of $3$; otherwise, that player loses (i.e., the other player wins).

For example, if the specified pattern is:

.o
oo

And the current board state is:

o..o.
o.o..
oo...
o.o..
o..o.

Then the given pattern is not considered to be formed (where o represents a piece and . represents an empty space). However, if a piece is placed at the second row and second column, the pattern is formed, with the corresponding pieces marked as @:

o..o.
o@o..
@@...
o.o..
o..o.

At this moment, there are exactly $11$ pieces on the board. Since $11$ is not a multiple of $3$, the player who placed this piece (the first player) loses the game.

At K's home, to save time, they usually play Three-Step Chess on an initially empty $5 \times 5$ board. At the same time, they randomly choose a 4-connected pattern consisting of no more than $4$ pieces. Obviously, there are no draws in Three-Step Chess, so K and H agree that the loser is responsible for cooking. K wants to know if the Three-Step Chess game played with the selected pattern is a first-player win, assuming both she and H are sufficiently intelligent; because if she is more likely to win, she wants to secretly let her sister win.

Input

Read from standard input.

The input contains multiple test cases.

The first line of the input contains a positive integer $T$, representing the number of test cases. It is guaranteed that $1 \le T \le 200$.

For each test case, the input contains $5$ lines, each consisting of a string of length $5$ containing only . and o, representing the specified pattern. It is guaranteed that in each test case, o appears at least once, and all os form a 4-connected component of size at most $4$.

Output

Output to standard output.

For each test case, output one line. If the input pattern is a first-player win, output Far; otherwise, output Away.

Examples

Input 1

3
.....
oo...
.....
.....
.....
.o...
.o...
.....
.....
.....
.....
.....
.....
.ooo.
.....

Output 1

Far
Far
Away

Note 1

This example contains three test cases.

For the first test case, the input pattern is a $1 \times 2$ oo. Obviously, no matter where the first player places their piece on the board, the second player has only two strategies:

  • Connect with the first player's piece to form oo. At this point, there are only $2$ pieces on the board, so the second player loses immediately.
  • Do not connect with the first player's piece to form oo, but when it is the first player's turn again, the first player can arbitrarily form oo. At this point, there are exactly $3$ pieces on the board, so the first player wins.

Regardless of the strategy, the second player cannot win, so for oo, it is a first-player win.

For the second test case, the input pattern is a $2 \times 1$ pattern, which is similar to oo, and it is a first-player win.

For the third test case, the input pattern is a $1 \times 3$ ooo, which can be proven to be a loss for the first player.

Constraints

It is guaranteed that $1 \le T \le 200$. For each test case, it is guaranteed that the $5 \times 5$ character matrix of . and o contains at least one o, and all os form a 4-connected component of size at most $4$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.