n = int(input()) if n % 2 == 0: print(2, n // 2, flush = True) a = n // 2 + 2 else: print(1, n // 2 + 1, flush = True) a = n // 2 + 2 while True: t = int(input()) if t < 2: break elif t == 2: k, x = map(int, input().split()) break else: k, x = map(int, input().split()) if k < a: print(k + a, x, flush = True) else: print(k - a, x, flush = True)