Guessing game

Xem dạng PDF

Gửi bài giải

Điểm: 0,01
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Tác giả:
Dạng bài
Ngôn ngữ cho phép
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

In a classroom, Van and Long are playing a game to determine who is smarter. At the beginning of the game, each person secretly writes down a positive integer: Long writes the number ~A~, while Van writes the number ~B~. Both numbers are then given to Chung, who is the referee of the game.

Chung then writes two numbers, ~X~ and ~Y~, on the blackboard such that at least one of the two numbers is equal to the sum of ~A~ and ~B~, meaning either ~X = A + B~, or ~Y = A + B~, or both.

The game begins. In each round, Chung asks Long: "Do you know Van's number?". If Long answers "No", then Chung asks Van the same question: "Do you know Long's number?". If Van also answers "No", the next round begins, repeating this process. The game continues until one of them answers "Yes", correctly stating the other person's number, and wins the game.

Both Van and Long are very intelligent and only answer "Yes" when they are completely sure of the other person's number. They know other player will do the same and they will play optimally based on all the information they have.

Chung is curious: with the initial numbers ~A~, ~B~, ~X~, and ~Y~ given, who will win the game—or will the game go on forever?

Input

The first line contains an integer ~t~ (~1 \leq t \leq 2 \times 10^5~) — the number of test cases.

Each of the following ~t~ lines contains four integers ~A~, ~B~, ~X~, and ~Y~ (~1 \leq A, B \leq 10^{18}~, ~2 \leq X, Y \leq 2 \times 10^{18}~) — representing the numbers chosen by Long, Van, and the two numbers written by Chung on the blackboard. It is guaranteed that at least one of the two numbers ~X~ or ~Y~ is equal to the sum of ~A~ and ~B~.

Output

For each test case, output the number of rounds in which the game ends and the name of the winner. If neither player can determine the other's number, output "Impossible".

Sample Input 1

2
3 4 7 7
2 10 5 12

Sample Output 1

1 Long
1 Van

Notes

In the first example, since ~X = Y = 7~ and Long's number is ~3~, the only possible value for the number that Van could write to satisfy the condition is ~4~. Therefore, Long can immediately deduce Van's number and win in the first round.

In the second example, in the first round, from Long's perspective, the possible values for ~B~ are ~3~ or ~10~, so Long cannot determine Van's number and must answer "No". As for Van, knowing that his number is ~B = 10~, and since ~10 < 5~ is unreasonable, Van can deduce that Long's number must be ~12 - 10 = 2~ and win in the first round.


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.