import sys N = int(input()) print((N + 1)//2, 2 - N % 2) sys.stdout.flush() while True: t = int(input()) if t == 0: exit() k, x = map(int, input().split()) if k == 1: print(N + 1 - x, 1) else: x += 1 print(N + 1 - x, 2) sys.stdout.flush()