This page is still under construction.

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

Paweł i Gaweł

Time limit3sMemory limit128 MB

Summary
Two players alternate moving a pawn across a grid, swapping floors whenever it enters a marked cell, each trying to hold the upper floor at the end.
Level

Medium6 of 10

Topics
Game theory, Dynamic programming, Matrix
Solved
No attempts yet

Problem

Paweł and Gaweł share one house: Paweł lives on the upper floor and Gaweł on the lower floor. When they first moved in, both wanted the upper floor, so they settled the dispute with a game.

The game is played on a board of N rows and M columns, divided into unit cells. A pawn starts on the corner cell at coordinates (1,1)(1, 1). The two players move in turn; on each move the pawn is pushed one cell forward, either to the next column or to the next row. This repeats until the pawn reaches the cell at coordinates (N,M)(N, M). Moving off the board is not allowed.

K of the cells are marked with a cross. Every time the pawn enters a marked cell, Paweł and Gaweł swap floors.

Paweł moves first, and at the start Paweł occupies the upper floor. The corner cell (1,1)(1, 1) is never marked. Assuming both players play optimally (each trying to end up on the upper floor), determine who lives on the upper floor when the pawn reaches (N,M)(N, M).

Here the coordinate (w,c)(w, c) denotes row ww, column cc. In other words, the lower-left corner, row 1 column 1, is the starting cell.

Input

The first line contains a natural number Z (1≤Z≤101 \le Z \le 10), the number of test sets. The sets follow in order.

The first line of each set contains three space-separated natural numbers N, M, and K (1≤N,M≤10001 \le N, M \le 1000; 0≤K≤N⋅M−10 \le K \le N \cdot M - 1), as described above.

Each of the next K lines contains the coordinates of one marked cell as two space-separated natural numbers wiw_i and cic_i (1≤wi≤N1 \le w_i \le N, 1≤ci≤M1 \le c_i \le M), the row and column of that cell.

Cell (1,1)(1, 1) is never marked, and all marked cells are distinct.

Output

For each test set, print one line: Pawel if Paweł can secure the upper floor no matter how his opponent moves, or Gawel if Gaweł can secure the upper floor no matter how his opponent moves.

Examples4

  1. Example 1

    Input
    4
    3 2 2
    2 1
    3 2
    4 3 3
    2 2
    3 3
    4 3
    20 20 6
    7 4
    3 7
    5 12
    5 5
    12 16
    9 18
    2 2 0
    
    Expected output
    Pawel
    Gawel
    Gawel
    Pawel
    
  2. Example 2

    Input
    1
    2 2 0
    
    Expected output
    Pawel
    
  3. Example 3

    Input
    1
    2 2 1
    1 2
    
    Expected output
    Pawel
    
  4. Example 4

    Input
    1
    2 2 1
    2 2
    
    Expected output
    Gawel