n = int(input()) if n % 2 == 0: print(2, n // 2, flush = True) a = n // 2 + 1 else: print(1, n // 2 + 1, flush = True) a = n // 2 + 1 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 x < a: print(k, x + a, flush = True) else: print(k, x - a, flush = True)