Banner Home Page Web Contests Problems Ranklist Status Statistics

Anniversary Cake

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other)
Total Submission(s) : 19   Accepted Submission(s) : 1
Problem Description
Nahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited person to determine the size of the piece of cake that he/she wants (which should also be square-shaped). She knows that Mr. Kavoosi would not bear any wasting of the cake. She wants to know whether she can make a square cake with that size that serves everybody exactly with the requested size, and without any waste.
 

Input
The first line of the input file contains a single integer t (1 ¡Ü t ¡Ü 10), the number of test cases, followed by input data for each test case. Each test case consist of a single line containing an integer s, the side of the cake, followed by an integer n (1 ¡Ü n ¡Ü 16), the number of cake pieces, followed by n integers (in the range 1..10) specifying the side of each piece.
 

Output
There should be one output line per test case containing one of the words KHOOOOB! or HUTUTU! depending on whether the cake can be cut into pieces of specified size without any waste or not.
 

Sample Input
2 4 8 1 1 1 1 1 3 1 1 5 6 3 3 2 1 1 1
 

Sample Output
KHOOOOB! HUTUTU!
 

Source
PKU
 

Statistic | Submit | Back