4495: J. Eat, Sleep, Repeat
内存限制:256 MB
时间限制:1 S
标准输入输出
题目类型:传统
评测方式:Special Judge
上传者:
提交:0
通过:0
题目描述
FuuFuu the Panda, together with Pico and Kotsuki, lives in the KFP apartment. As a rare species, FuuFuu is well-treated. Therefore, his daily activities are only eating and sleeping.
One afternoon, Kotsuki is still working outside, and FuuFuu has finished his lunch and intends to go to sleep. But Pico feels too bored to play alone every day and wants to play a game with FuuFuu for a while. Although not very reluctant, FuuFuu agrees.
Pico picks n integers a1, a2, ... an, and sets k constraints, the i-th of which is limitxi=yi, indicating that the maximum number of occurrences of xi is yi. Then Pico and FuuFuu take turns playing the game, where each player can choose a positive integer among a1, a2, ... an for each turn and reduce it by 1. A player will lose the game if he cannot perform any action on his turn, where there are two cases:
- No matter which of a1,a2,…an is chosen, there exists an integer x whose number of occurrences will be strictly greater than limitx.
- a1=a2=⋯=an=0.
输入格式
The first line contains an integer T (1 ≤ T ≤ 105), indicating the number of test cases.
The first line of each test case contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 105), indicating the number of integers and constraints.
The second line contains n integers a1, a2, ... an (0 ≤ ai ≤ 109), indicating the initial integers. It is guaranteed that the initial number of occurrences of each integer does not exceed the limit.
The i-th of the following k lines contains two integers xi and yi (0 ≤ xi ≤ 109, 0 ≤ yi ≤ n), indicating that limitxi=yi. It is guaranteed that x1, x2, ... xk are all distinct.
It's guaranteed that ∑ n ≤ 105 and ∑ k ≤ 105 over all test cases.
The first line of each test case contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 105), indicating the number of integers and constraints.
The second line contains n integers a1, a2, ... an (0 ≤ ai ≤ 109), indicating the initial integers. It is guaranteed that the initial number of occurrences of each integer does not exceed the limit.
The i-th of the following k lines contains two integers xi and yi (0 ≤ xi ≤ 109, 0 ≤ yi ≤ n), indicating that limitxi=yi. It is guaranteed that x1, x2, ... xk are all distinct.
It's guaranteed that ∑ n ≤ 105 and ∑ k ≤ 105 over all test cases.
输出格式
For each test case, output the name of the winner in a single line, which is either Pico or FuuFuu.
输入样例 复制
5
2 0
1 2
2 1
1 2
0 1
3 2
3 3 4
0 2
1 1
3 2
2 3 3
1 2
0 1
5 4
6 7 8 12 17
1 1
2 1
9 0
10 1
输出样例 复制
Pico
FuuFuu
Pico
FuuFuu
Pico
数据范围与提示
For the first test case of the sample, since there are no constraints, the game ends only if all the integers are reduced to zero. So FuuFuu will lose the game after three turns.
For the second test case of the sample, the maximum number of occurrences of 0 is 1. Obviously, there must be two zeros after Pico's action in the third turn, so FuuFuu will win the game.
For the second test case of the sample, the maximum number of occurrences of 0 is 1. Obviously, there must be two zeros after Pico's action in the third turn, so FuuFuu will win the game.