import sys input = sys.stdin.readline from itertools import combinations,permutations from random import randint,shuffle X=list(range(10)) L=list(combinations(X,5)) USE=set() while True: shuffle(L) x=L.pop() print("".join(map(str,x)),flush=True) C=0 A=0 for i in range(30): h,b=map(int,input().split()) if h+b==5 and h!=5: C+=1 A+=1 if h==5 and b==0: A+=1 if C>1: L2=list(permutations(x)) while True: shuffle(L2) x2=L2.pop() print("".join(map(str,x2)),flush=True) C=0 for i in range(30): h,b=map(int,input().split()) if h==5 and b==0: C+=1 if A==C: break