n = int(input()) if(n & 1): print(*[1, n // 2 + 1]) else: print(*[2, n // 2]) while(int(input()) not in [0, 1]): k, x = map(int, input().split()) if(n & 1 and k == 1): m = n // 2 + 1 print(*[1, x + (m - x) * 2]) elif(n & 1): m = n // 2 + 1 print(*[2, x + (m - x) * 2 - 1]) elif(k == 1): m = n // 2 print(*[1, x + (m - x) * 2 + 1]) else: m = n // 2 print(*[2, x + (m - x) * 2])