from math import gcd import sys, time, random from collections import deque, Counter, defaultdict def debug(*x):print('debug:',*x, file=sys.stderr) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 S = set() for month in range(1, 13): for day in range(1, 32): if month in [4, 6, 9, 11] and day == 31: continue if month == 2 and day > 29: continue st = str(month).zfill(2) + str(day).zfill(2) if len(set(st)) == 4: S.add(st) ST = [] for i1 in range(3): for i2 in range(3): for i3 in range(3): for i4 in range(10): if i1 == i2 or i1 == i3 or i1 == i4 or i2 == i3 or i2 == i4 or i3 == i4: continue st = str(i1) + str(i2) + str(i3) + str(i4) ST.append(st) def solve(): nowS = set(S) deb = False if deb: ANS = random.choice(list(nowS)) debug(ANS) for q in range(6): bestq = None bestmax = inf bestans = None for st in ST: ans = defaultdict(list) for v in nowS: h = 0 b = 0 for i in range(4): if st[i] == v[i]: h += 1 elif st[i] in v: b += 1 ans[(h, b)].append(v) V = [len(v) for v in ans.values()] if max(V) < bestmax: bestmax = max(V) bestq = st bestans = ans print('?', bestq, flush=True) if deb: h = 0 b = 0 for i in range(4): if bestq[i] == ANS[i]: h += 1 elif bestq[i] in ANS: b += 1 else: h, b = mi() nowS = bestans[(h, b)] if len(nowS) == 1: A = nowS.pop() print('!', A, flush=True) if deb: if A == ANS: a = 0 else: a = -1 else: a = ii() if a == 0: pass else: raise ValueError return for _ in range(ii()): solve()