split()
을 적절히 사용해서 울음소리가 들어있는지 아닌지 판별해서 조건에 맞는 울음소리만을 출력하면 된다.
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
sound_lst = list(map(str, input().strip().split()))
result = []
temp = []
while True:
input_string = input().strip()
if input_string == "what does the fox say?":
break
else:
li = list(input_string.split(" "))
temp.append(li[-1])
for i in sound_lst:
if i not in temp:
result.append(i)
print(*result)