import sys from itertools import permutations sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) A = [] for i in range(5): print((4*i)%10,(4*i+1)%10,(4*i+2)%10,(4*i+3)%10,flush=True) X,Y = MI() if X == 4: exit() A.append(X+Y) count = [0,0,0,0,0] for i in range(5): count[i] = A[(3*i)%5]+A[(3*i+1)%5]-4 ANS = [] B = [] for i in range(5): if count[i] == 2: ANS.append(2*i) ANS.append(2*i+1) elif count[i] == 1: B.append((2*i,2*i+1)) l = len(B) for i in range(2**l): question = [] for j in range(l): question.append(B[j][(i>>j) & 1]) if l == 4: N1,N2,N3,N4 = question else: N1,N2 = question N3,N4 = ANS print(N1,N2,N3,N4,flush=True) X,Y = MI() if X == 4: exit() if X+Y == 4: ANS += question break for ans in list(permutations(ANS,4)): N1,N2,N3,N4 = ans print(N1,N2,N3,N4,flush=True) X,Y = MI() if X == 4: exit()