Banner Home Page Web Contests Problems Ranklist Status Statistics

PP and QQ

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 0   Accepted Submission(s) : 0
Problem Description
PP and QQ were playing games at Christmas Eve. They drew some Christmas trees on a paper: <br><br><center><img src=../../data/images/C305-1008-1.jpg></center><br><br>Then they took turns to cut a branch of a tree, and removed the part of the tree which had already not connected with the root. A step shows as follows: <br><br><center><img src=../../data/images/C305-1008-2.jpg></center><br><br>PP always moved first. <br>PP and QQ took turns (PP was always the first person to move), to cut an edge in the graph, and removed the part of the tree that no longer connected to the root. The person who cannot make a move won the game. <br>Your job is to decide who will finally win the game if both of them use the best strategy. <br>
 

Input
The input file contains multiply test cases.<br>The first line of each test case is an integer N (N<100), which represents the number of sub-trees. The following lines show the structure of the trees. The first line of the description of a tree is the number of the nodes m (m<100). The nodes of a tree are numbered from 1 to m. Each of following lines contains 2 integers a and b representing an edge <a, b>. Node 1 is always the root. <br>
 

Output
For each test case, output the name of the winner.
 

Sample Input
2<br>2<br>1 2<br>2<br>1 2<br>1<br>2<br>1 2<br>
 

Sample Output
PP<br>QQ<br>
 

Author
alpc27
 

Source
2010 ACM-ICPC Multi-University Training Contest£¨15£©¡ª¡ªHost by NUDT
 

Statistic | Submit | Back