QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#7299. Stone Game

统计

Stone Game

Roland P. Sprague and Patrick M. Grundy were both enthusiasts of combinatorial games, but they had never met.

One day, in a letter to Grundy, Sprague introduced an ancient game allegedly from the East—the Stone Game.

The Stone Game is a two-player game. At the beginning of the game, there are several piles of stones on the table. The two players take turns: a player chooses a pile and removes any number of stones from it (but must remove at least one). The player who cannot make a move loses, and the other player wins.

Due to limited conditions, Sprague suggested writing a row of natural numbers on a piece of paper to represent the number of stones in each pile, and then the two players would take turns crossing out numbers and writing new ones. Grundy gladly agreed.

A month later, after Grundy had lost five games in a row, he suspected Sprague of cheating. After a few days of research, Grundy discovered one afternoon that if both players are sufficiently intelligent, there is a very simple way to determine whether the first player or the second player will win, given an initial state (a row of natural numbers), and one can even provide a winning strategy! Thus, Grundy decided to strike back.

The next day, in a letter to Sprague, Grundy suggested making the game rules more complex: first, determine a constant $K$. Then, the rules for both players change: each turn, a player chooses a number to cross out. Suppose the number is $x$. The player can choose a positive integer $a$, and after crossing out $x$, they must write down $K$ numbers: $x - a, x - 2a, \dots, x - Ka$, provided that $x - Ka \ge 0$. If no such $a$ exists, the player cannot cross out this number $x$. The condition for losing remains the same: the player who cannot make a move loses.

Out of pride, Sprague could not refuse. However, he would not sit idly by. Now he has obtained $K$ and the $N$ numbers written on the paper. He has told you—John von Neumann—all this data and the rules of the game, as you are a mathematician, physicist, economist (and computer scientist) studying how to use a machine that does not yet exist (which you have named a computer) to solve practical problems.

Input

The first line contains a positive integer $T$, representing the number of test cases (the number of times Sprague asks you). Then $T$ test cases follow. Each test case occupies $N + 2$ lines, formatted as follows:

The first line is an empty line. The second line contains two positive integers, $N$ and $K$, in that order. The next $N$ lines each contain a positive integer, representing the $N$ numbers written on the paper.

Output

The output contains $T$ lines. For each test case, if the first player has a winning strategy, output "Preempt.". If the second player has a winning strategy, output "Leapfrog.". If neither is the case, output "Je suis un imbecile.".

Examples

Input 1

2

1 1
1

2 30
197943
249832

Output 1

Preempt.
Leapfrog.

Constraints

  • 10% of the data: $N \le 5, K = 1$, all numbers $\le 5$.
  • 20% of the data: $N \le 100, K = 1$, all numbers $\le 10^9$.
  • 10% of the data: $N \le 100, K = 2$, all numbers $\le 10^9$.
  • 20% of the data: $N \le 100, K = 2$, all numbers $\le 10^{18}$.
  • 20% of the data: $N \le 100, K = 10$, all numbers $\le 10^{18}$.
  • 40% of the data: $N \le 100, K = 30$, all numbers $\le 10^{80}$.
  • 100% of the data: $T \le 10$.

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.