## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Chef & Cook Game CodeChef Solution

## Problem

There is a non-negative integer array $A$ of length $N$. Chef and Cook will play a game on the array with Chef starting first.

In one turn the player will perform the following operation:

• Choose two indices $i,j$ such that $1 \leq i \lt j \leq N$ and $A_i \gt 0$.
• Set $A_i \gets A_i - 1$ and $A_j \gets A_j + 1$, i.e, subtract $1$ from $A_i$ and add $1$ to $A_j$.

The player who is unable to perform the operation loses. If both Chef and Cook play optimally, who will win?

### Input Format

• The first line of input will contain a single integer $T$, denoting the number of test cases.
• The first line of each test case contains a single integer $N$ denoting the length of the array.
Solution Click Below:-  👉
👇👇👇👇👇

• The second line of teach test case contains $N$ integers $A_1,A_2,\ldots,A_N$ denoting the initial values of the array.

### Output Format

For each test case, output "Chef" if Chef wins, otherwise output "Cook" (without quotes).

Each letter of the output may be printed in either uppercase or lowercase. For example, ChefchEfCHEF, and cHEf will all be treated as equivalent.

### Explanation:

For the first test case, Chef wins. Here is the strategy for Chef.

• Initially, $A = [1, 0, 1, 0]$.
• In the first turn, Chef will pick $i=1$ and $j=3$. Then, $A = [0,0,2,0]$.
• In the second turn, Cook is can only pick $i=3$ and $j=4$. Then $A=[0,0,1,1]$.
• In the third turn, Chef will pick $i=3$ and $j=4$. Then $A=[0,0,0,2]$.
• In the fourth turn, Cook cannot perform any operation and loses. Therefore, Chef has won.