This page is still under construction.

Parts of this page are still being built. What you see may change.

Presidential Game

Time limit1sMemory limit512 MB

Summary
Two players alternately merge 2 to K adjacent elements, John by sum and Preston by XOR, until one value remains; decide who wins when John needs the final value odd.
Level

Hard8 of 10

Topics
Game theory, Dynamic programming, Math, Bit manipulation
Solved
No attempts yet

Problem

Two candidates are running in this year's presidential election, John Wee and Preston Wo. Taking a break from promoting their campaigns, they decide to play a game with an array AA of NN integers. The candidates make alternating moves until a single element remains, starting with John, the current president.

In each turn, John chooses a contiguous subarray of AA containing between 22 and KK elements, inclusive, and replaces the subarray with a single element equal to the sum of all elements in the subarray. In each turn, Preston chooses a contiguous subarray of AA containing between 22 and KK elements, inclusive, and replaces the subarray with a single element equal to the bitwise XOR of all elements in the subarray. The bitwise XOR of an array of integers XX is defined as follows, where ⊕\oplus denotes the bitwise XOR operator.

XOR(X)={X1⊕X2if ∣X∣=2XOR([X1,X2,…,X∣X∣−1])⊕X∣X∣if ∣X∣>2XOR(X) = \begin{cases} X_1 \oplus X_2 & \text{if }|X| = 2 \\ XOR([X_1, X_2, \dots, X_{|X|-1}]) \oplus X_{|X|} & \text{if }|X| > 2 \end{cases}

Since John is candidate number 1, John wins the game if the single element left in the array is odd. Otherwise, if the single element left in the array is even, Preston wins the game. You want to predict who wins the game when both candidates play optimally.

Input

The first line contains two integers NN KK (2≤K≤N≤10002 \le K \le N \le 1000), the length of the array and the maximum length of the subarray that can be chosen in each turn. The next line contains NN integers AiA_i (0≤Ai≤10000 \le A_i \le 1000), the array AA.

Output

Output in a single line the name of the winner, either John or Preston.

Examples2

  1. Example 1

    Input
    4 3
    2 0 3 4
    
    Expected output
    John
    
  2. Example 2

    Input
    3 2
    1 2 1
    
    Expected output
    Preston