a = [0, 0, 0, 0] b = [0, 1, 2, 3] c = a[:] n = 0 f = 1 for i in range(10): print(i, i+3, i+6, i+9) x, y = map(int, input().split()) if x > 3 : f = 0 break if x + y < 1: b = [i, i+3, i+6, i+9] break a = b[:] while f: a[n] = (a[n]+1)%10 if a[n] in b: continue print(a[0], a[1], a[2], a[3]) x, y = map(int, input().split()) if x > 0: c[n] = a[n] n += 1 a = b[:] if n > 3: print(c[0], c[1], c[2], c[3]) break