#!/usr/bin/env python3 #coding:utf-8 import math import string from sys import stdin # import numpy as np # from matplotlib import pyplot as plt def main(): read=stdin.readline #edit here! n=int(read()) if n%2==1: print(1,(n+1)//2,flush=True) else: print(2,n//2,flush=True) while True: t=int(read()) if t==0: break else: k,x=map(int,read().split()) if x>(n+1)//2: y=n//2+1 print(k,x-y,flush=True) else : y=n//2+1 print(k,x+y,flush=True) if __name__ == '__main__': main()