In a regular table tennis match, the player who serves changes every time after 2 points are scored, regardless of which players scored them.
Chef and Cook are playing a different match — they decided that the player who serves would change every time after $K$ points are scored instead (again regardless of which players scored them). When the game starts, it's Chef's turn to serve.
You are given the current number of points scored by Chef and Cook ($P_1$ and $P_2$ respectively). Find out whether Chef or Cook has to serve next.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains three space-separated integers $P_1$, $P_2$ and $K$.

-----Output-----
For each test case, print a single line containing the string "CHEF" if it is Chef's turn or "COOK" if it is Cook's turn.

-----Constraints-----
- $1 \le T \le 10^5$
- $1 \le K \le 10^{9}$
- $0 \le P_1, P_2 \le 10^{9}$ 

-----Subtasks-----
Subtask #1 (100 points): original constraints

-----Example Input-----
3
1 3 2
0 3 2
34 55 2

-----Example Output-----
CHEF
COOK
CHEF

-----Explanation-----
Example case 1: Chef serves for the first two points, Cook serves for the next two, so Chef has to serve again now.

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc


Solutions:
for i in range(int(input())):
	(p1, p2, k) = map(int, input().split())
	if (p1 + p2) // k % 2:
		print('COOK')
	else:
		print('CHEF')


t = int(input())
while t > 0:
	(p1, p2, k) = map(int, input().split())
	if (p1 + p2) // k % 2 == 0:
		print('CHEF')
	else:
		print('COOK')
	t -= 1


t = int(input())
for i in range(t):
	(l, m, k) = map(int, input().split())
	a = l + m + 1
	if a % k == 0:
		b = a / k
	else:
		b = int(a / k) + 1
	if b % 2 == 0:
		print('COOK')
	else:
		print('CHEF')


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	k = l[0] + l[1]
	k = k % (2 * l[2])
	if k >= 0 and k < l[2]:
		print('CHEF')
	else:
		print('COOK')


cases = int(input())
for i in range(cases):
	(chefScore, cookScore, changePoint) = map(int, input().split())
	sumScore = chefScore + cookScore
	serveNumber = sumScore // changePoint
	if serveNumber % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


T = int(input(''))
for i in range(T):
	(P, Q, K) = [int(x) for x in input('').split()]
	Y = (P + Q) % (2 * K)
	if Y in range(0, K):
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(p1, p2, k) = map(int, input().split())
	x = (p1 + p2) // k
	if x % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	t = (a + b) // k
	if t % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for i in range(int(input())):
	a = [int(x) for x in input().split()]
	d = a[0] + a[1]
	d = d % (a[2] * 2)
	if d < a[2] * 2 // 2:
		print('CHEF')
	else:
		print('COOK')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	if (a + b) // c % 2:
		print('COOK')
	else:
		print('CHEF')


for _ in range(int(input())):
	(P1, P2, k) = list(map(int, input().split()))
	d = (P1 + P2) // k
	if d % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	l = a + b
	s = l // c
	if s % 2 == 0:
		print('CHEF')
	else:
		print('COOK')
	t = t - 1


t = int(input())
for r in range(t):
	(p1, p2, k) = map(int, input().split())
	x = p1 + p2
	y = x // k
	if y % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for j in range(t):
	(p1, p2, k) = list(map(int, input().split()))
	x = p1 + p2
	x = x // k
	if x % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for tc in range(t):
	(p1, p2, k) = map(int, input().split())
	s = p1 + p2
	if s // k % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for i in range(0, int(input())):
	list1 = list(map(int, input().split()))
	if (list1[0] + list1[1]) // list1[2] % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for t in range(int(input())):
	(p1, p2, k) = map(int, input().split())
	if (p1 + p2) // k % 2 == 1:
		print('COOK')
	else:
		print('CHEF')


T = int(input())
for _ in range(T):
	(p1, p2, k) = map(int, input().split())
	num = p1 + p2
	if num % k:
		res = num // k
		if res % 2:
			print('COOK')
		else:
			print('CHEF')
	else:
		res = num // k
		if res % 2:
			print('COOK')
		else:
			print('CHEF')


try:
	for _ in range(int(input())):
		(p1, p2, k) = list(map(int, input().split()))
		if (p1 + p2) // k % 2 == 0:
			print('CHEF')
		else:
			print('COOK')
except:
	pass


import collections
from collections import defaultdict
import math
for _ in range(int(input())):
	(p1, p2, k) = [int(x) for x in input().split()]
	r = math.floor((p1 + p2) / k)
	if r % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for i in range(t):
	(p1, p2, k) = list(map(int, input().split()))
	p = 0
	p = p1 + p2
	d = 0
	d = p // k
	if d % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	p = a + b
	q = p % (2 * c)
	if q < c:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	z = x + y
	cou = 0
	for i in range(z):
		if z < k:
			break
		z = z - k
		cou = cou + 1
	if cou % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for i in range(int(input())):
	(p, q, k) = map(int, input().split())
	c = (p + q) // k
	if c % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


T = int(input())
for i in range(T):
	(A, B, C) = map(int, input().split())
	S = (A + B) // C
	if S % 2 == 1:
		print('COOK')
	else:
		print('CHEF')


T = int(input())
for _ in range(T):
	(a, b, k) = map(int, input().split())
	turn = (a + b) % (2 * k)
	if turn < k:
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(p1, p2, k) = list(map(int, input().split()))
	p = p1 + p2
	a = p // k
	if a % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for t in range(int(input())):
	(p, q, k) = map(int, input().split())
	s = p + q
	d = s // k
	if d % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


import math
t = int(input())
for _ in range(t):
	(p1, p2, k) = map(int, input().split())
	val = math.ceil((p1 + p2 + 1) / k)
	if val % 2 != 0:
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(a, b, k) = [int(i) for i in input().split()]
	x = (a + b) // k
	if x % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for j in range(int(input())):
	(a, b, c) = map(int, input().split())
	if (a + b) // c % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for i in range(t):
	(a, b, k) = [int(i) for i in input().split()]
	print('CHEF') if (a + b) % (2 * k) < k else print('COOK')


for _ in range(int(input())):
	(chef, cook, k) = map(int, input().split())
	ans = (chef + cook) // k
	if ans % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for k in range(int(input())):
	(p1, p2, w) = map(int, input().split())
	u = p1 + p2
	u //= w
	if u % 2:
		print('COOK')
	else:
		print('CHEF')


def serves():
	if (p1 + p2) // k % 2 == 0:
		return 'CHEF'
	else:
		return 'COOK'
for _ in range(int(input())):
	(p1, p2, k) = map(int, input().split())
	print(serves())


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	c = a + b
	d = c // k
	if d % 2 == 0:
		print('CHEF')
	elif d % 2 != 0:
		print('COOK')


for _ in range(int(input())):
	(x, y, n) = map(int, input().split())
	if (x + y) // n % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for i in range(int(input())):
	(P1, P2, K) = map(int, input().split())
	c = (P1 + P2) // K
	if c % 2 != 0:
		print('COOK')
	else:
		print('CHEF')


for _ in range(int(input())):
	(P1, P2, K) = [i for i in map(int, input().split())]
	total_points = P1 + P2
	points = total_points // K
	players = ['CHEF', 'COOK']
	print(players[points % 2])


q = int(input())
for i in range(q):
	(p1, p2, k) = map(int, input().split())
	p = p1 + p2
	a = p // k
	if a % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for _ in range(t):
	[p1, p2, k] = list(map(int, input().split()))
	tot = p1 + p2
	q = tot // k
	if q % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for i in range(int(input())):
	(p1, p2, K) = map(int, input().split())
	print('CHEF' if (p1 + p2) // K % 2 == 0 else 'COOK')


def serve(p1, p2, k):
	server = 'CHEF'
	n = (p1 + p2) // k
	if n % 2 != 0:
		server = 'COOK'
	else:
		server = 'CHEF'
	return server
for t in range(int(input())):
	(p1, p2, k) = map(int, input().split(' '))
	print(serve(p1, p2, k))


for _ in range(int(input())):
	(P1, P2, K) = map(int, input().split())
	p = (P1 + P2) // K
	if p % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(p1, p2, k) = map(int, input().split())
	s = p1 + p2 + 1
	if s % k == 0:
		c = s / k
	else:
		c = int(s / k) + 1
	if c % 2 == 0:
		print('COOK')
	else:
		print('CHEF')


t = int(input())
for _ in range(t):
	line = input()
	words = line.split()
	nums = [int(w) for w in words]
	(p1, p2, k) = nums
	s = p1 + p2
	c = s // k
	if c % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


for _ in range(int(input())):
	(chef, cook, points) = map(int, input().split())
	find = (chef + cook) % (2 * points)
	if find in range(0, points):
		print('CHEF')
	else:
		print('COOK')


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	x = a + b
	if x // c % 2 == 0:
		print('CHEF')
	else:
		print('COOK')


def sol():
	ans = 0
	(p1, p2, k) = map(int, input().split())
	x = (p1 + p2) // k
	if x % 2 == 0:
		return 'CHEF'
	else:
		return 'COOK'
for _ in range(int(input())):
	print(sol())


for i in range(int(input())):
	(a, b, k) = map(int, input().split())
	d = a + b
	d = d % (k * 2)
	if d < k * 2 // 2:
		print('CHEF')
	else:
		print('COOK')