def g(x,v): aa = bb = 0 for i in range(4): if v[i] == x[i]: aa += 1 elif v[i] in x: bb += 1 return aa,bb def check(x,v,a,b): aa,bb = g(x,v) return aa==a and bb==b def query(v): print(*v) if DEBUG: a,b = g(v,ans) else: a,b = map(int,input().split()) return a,b DEBUG = 0 ans = "1864" from itertools import permutations s = {"".join(map(str,i)) for i in permutations(range(10),4)} c = 0 while True: v = s.pop() a,b = query(v) if a==4: exit() ns = set() for i in s: if check(i,v,a,b): ns.add(i) s = ns