import random N = int(input()) d = [0] * N print(1, 1) d[0] = 1 while True: t = int(input()) if t in [0, 1]: break k, x = map(int, input().split()) d[x - 1] = 1 if k == 2: d[x] = 1 if t == 2: break for i in range(N): c = [] if d[i] == 0: c.append(d) x = random.choice(c) d[x] = 1 print(1, x + 1)