P17480 [CodeChef] SPLITORDEC
提高+
题目描述

Chef and Chefina are playing a game. Chef plays first.

There are N piles where the i^{th} pile contains A_{i} stones.

In his/her turn, a player can do one of the following:

Take any non-empty pile and remove 1 stone from it.
Take any pile containing atleast 2 stones and split it into two piles containing X and Y stones such that X+Y equals the initial number of stones in the chosen pile. Note that in this case, the number of piles increases by 1.

The player who cannot make a move loses. Determine the winner if both players play optimally.

------ Input Format ------

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of multiple lines of input.
  • The first line of each test case contains a single integer N - denoting the initial number of piles.
  • The next line contains $N space separated integers A_{1}, A_{2}, A_{3}, \dots, A_{N}$, the number of stones initially in each pile.

------ Output Format ------

For each test case, output CHEF if Chef wins the game, and CHEFINA otherwise.

You may print each character in uppercase or lowercase. For example, the strings CHEF, chef, Chef, and cHEf are all considered identical.

------ Constraints ------

$1 ≤ T ≤ 1000$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases does not exceed $3 \cdot 10^{5}$.

----- Sample Input 1 ------
3
2
3 3
5
2 1 1 1 1
3
2 2 2

----- Sample Output 1 ------
CHEFINA
CHEF
CHEF

----- explanation 1 ------
Test case $1$: Consider the following set of moves:
- Chef splits the first pile into two piles. Thus, after his move, the piles are $[1, 2, 3]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[2, 3]$.
- Chef splits the first pile into two piles. Thus, after his move, the piles are $[1, 1, 3]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[1, 3]$.
- Chef splits the second pile into two piles. Thus, after his move, the piles are $[1, 1, 2]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[1, 2]$.
- Chef takes a stone from the first pile. Thus, after his move, the piles are $[2]$.
- Chefina splits the first pile into two piles. Thus, after her move, the piles are $[1, 1]$.
- Chef takes a stone from the first pile. Thus, after his move, the piles are $[1]$.
- Chefina takes a stone from the first pile. Thus, after her move, all piles are empty.

Since Chef has no valid move, he loses. Note that this might not be an optimal sequence of moves.

Test case $2$: Consider the following set of moves:
- Chef splits the first pile into two piles. Thus, after his move, the piles are $[1, 1, 1, 1, 1, 1]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[1, 1, 1, 1, 1]$.
- Chef takes a stone from the first pile. Thus, after his move, the piles are $[1, 1, 1, 1]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[1, 1, 1]$.
- Chef takes a stone from the first pile. Thus, after his move, the piles are $[1, 1]$.
- Chefina takes a stone from the first pile. Thus, after her move, the piles are $[1]$.
- Chef takes a stone from the first pile. Thus, after his move, all piles are empty.

Since Chefina has no valid move, she loses. Note that this might not be an optimal sequence of moves.

输入格式

见题面

输出格式

见题面

样例输入
3 2 3 3 5 2 1 1 1 1 3 2 2 2
样例输出
CHEFINA CHEF CHEF