N = int(input()) used = [0 for _ in range(N + 2)] used[0] = 1 used[N + 1] = 1 while True: cnt = 0 for i in range(0, N + 1): if used[i] and not used[i + 1]: cnt += 1 if cnt % 2 == 1: for i in range(0, N): if used[i] and not used[i + 1] and used[i + 2]: used[i + 1] = 1 print(1, i + 1) break else: for i in range(0, N - 1): if used[i] and not used[i + 1] and not used[i + 2] and used[i + 3]: used[i + 1] = 1 used[i + 2] = 1 print(2, i + 1) break else: for i in range(0, N): if not used[i + 1]: used[i + 2] = 1 print(1, i + 2) break t = int(input()) if t == 0: break elif t == 1: raise Exception elif t == 2: raise Exception else: k, x = map(int, input().split()) if k == 1: used[x] = 1 else: used[x] = 1 used[x + 1] = 1