import sys from collections import defaultdict def solve before for in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
from collections import defaultdict
def solve():
r = []
before = [i*5+1 for i in range(119)]
while len(r) < 4:
d = defaultdict(lambda: [])
for position in before:
print(position)
sys.stdout.flush()
let = input()
d[let].append(position)
mv = None
for let in d.keys():
if mv is None or len(d[mv]) > len(d[let]):
mv = let
r.append(mv)
before = [k+1 for k in d[mv]]
for let in list('ABCDE'):
if let not in r:
r.append(let)
# swap last 2 letters
r[-2], r[-1] = r[-1], r[-2]
print(''.join(r))
sys.stdout.flush()
tc, mc = map(int, input().split(' '))
for tnum in range(tc):
solve()
te = input()
if te == 'N':
break