The problem of the century: "What do you have for dinner?" Lazy_sheep's girlfriend asked. "We just finished lunch!" Lazy_sheep looked at the restaurant's recipe and replied helplessly. As a century puzzle...

Title description

"What's for dinner?" Lazy_sheep's girlfriend asked.
"We just finished lunch!" Lazy_sheep looked at the restaurant's recipe and replied helplessly.
As a century-old problem, "what to eat for dinner" has always plagued Lazy_sheep.
It is known that a positive integer is written before each dish in the restaurant's recipe as the dish number, and his girlfriend can remember which dishes he ate for the first n meals. If today's dinner is the same as one of the previous n meals, she will be unhappy.
Now Lazy_sheep casually said a certain number w, please help to determine if it will cause your girlfriend to be unhappy.

Input data

There is an integer t (1 ≤ t ≤ 100) in the first line, which means there are t groups of data. For each set of data: the
first row has a positive integer w (1 ≤ w ≤ 50), which represents the dish number spoken by Lazy_sheep; the
second row has a positive integer n (1 ≤ n ≤ 20); the
third row has n A different positive integer ai (1 ≤ i ≤ n, 1 ≤ ai ≤ 50), which represents the number of the dishes eaten for the first n meals.

Output Data

For each set of data: if w is the number of the dishes eaten in the first n meals, output a line of "unhappy", otherwise output "happy".

Sample input

2
1
3
1 2 3
5
5
1 8 7 4 6

Sample output

unhappy
happy

Experience: in keyword can determine whether to include

T = int(input())    
for t in range(T):      
    w = int(input())      
    temp = input()          
    s = [int(item) for item in input().split()]      
    if w in s:          
        print('unhappy')      
    else:          
        print('happy')  

Guess you like

Origin blog.csdn.net/tianxiefenxiang/article/details/107563974