Problem description

Chutes and Ladders is a board game played on a 10x10 grid. The squares of the grid are numbered 1 to 100. Each player is represented by a game piece token, which is placed on the square numbered 1 at the beginning of the game. Each player takes turns rolling a single die to move the token by the number of squares indicated by the die roll. If this would put the token past the square numbered 100, the token is advanced to 100. If, on completion of a move, a player's token lands on the bottom end of a ladder, the token is moved to the top of the ladder. If the player lands on the top of a chute, the token is moved to the bottom of the chute. No square contains more than one end of any chute or ladder. The square numbered 100 does not contain the top of a chute or the bottom of a ladder. The player who is first to bring their token to the square numbered 100 is the winner. At that point, the game ends.

Given the configuration of the chutes and ladders on a game board and a sequence of die rolls, determine the positions of all the tokens on the game board. The sequence of die rolls need not lead to any player winning. The sequence of die rolls may also continue after the game is over; in this case, the die rolls after the end of the game should be ignored.

Input

The first line is the number of test cases to follow. The test cases follow, one after another. The format of each test case is the following:

The first line contains three positive integers: the number a of players, the number b of chutes or ladders, and the number c of die rolls. There will be no more than 1,000,000 players and no more than 1,000,000 die rolls. Each of the next b lines contains two integers specifying a chute or ladder. The first integer indicates the square containing the top of the chute or the bottom of the ladder. The second integer indicates the square containing the bottom of the chute or the top of the ladder. The following c lines each contain one integer giving the number rolled on the die.

Output

For each player, output a single line containing a string of the form 'Player N is on square P.' where N is replaced with the number of the player and P is replaced with the final position of the player.

Sample Input

1
3 1 3
4 20
3
4
5

Sample Output

Player 1 is on square 20.
Player 2 is on square 5.
Player 3 is on square 6.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.