## Problemi 204

### Zgjidhja

### To test this program with testing_tool.py first create a pipe (fifo) file:
### $mkfifo pipe ### Then run it like this: ###$ python3 testing_tool.py 0 < pipe | python3 program.py > pipe
### \$ python3 testing_tool.py 1 < pipe | python3 program.py > pipe

import sys

sys.stderr.write(">> {}\n".format(i+1))
print(i + 1)
sys.stdout.flush()
sys.exit()

sys.stderr.write(">> {}\n".format(ans))
print(''.join(ans))
sys.stdout.flush()
sys.exit()

letters = ['A', 'B', 'C', 'D', 'E']

T, F = [int(i) for i in input().split()]
for t in range(T):
M = [['' for i in range(5)] for j in range(119)]
ans = ['', '', '', '', '']

# ask 119 questions and find the first char of the answer
for i in range(119):
freq = {}
for c in [M[i] for i in range(119)]:
freq[c] = freq.get(c, 0) + 1
for c in freq.keys():
if freq[c] == 23:
ans = c

# ask 23 questions and find the second char of the answer
for i in range(119):
if M[i] != ans:
continue
freq = {}
for c in [M[i] for i in range(119)]:
freq[c] = freq.get(c, 0) + 1
for c in freq.keys():
if freq[c] == 5:
ans = c

# ask 5 questions and find the third char of the answer
for i in range(119):
if M[i] != ans or M[i] != ans:
continue
freq = {}
for c in [M[i] for i in range(119)]:
freq[c] = freq.get(c, 0) + 1
for c in freq.keys():
if freq[c] == 1:
ans = c

# ask 1 more question and find the forth char
for i in range(119):
if M[i] != ans or M[i] != ans or M[i] != ans:
continue
answer(ans)