N = int(input()) if N % 2 == 0: print(2, N // 2) else: print(1, (N + 1) // 2) while True: t = int(input()) if t == 0: break elif t == 1 or t == 2: raise Exception else: k, x = map(int, input().split()) if k == 1: print(1, N + 1 - x) else: print(2, N - x)