import itertools N = int(input()) MAP = [0]*(N+1) MAP[0]=1 while True: gr = itertools.groupby(MAP) i = 0 for k,g in gr: lg = len(list(g)) if k==0 and lg==4: print(2,i+1) MAP[i+1]=1 MAP[i+2]=1 break if k==0 and lg>=3: print(1,i+1) MAP[i+1]=1 break i+=lg else: gr = itertools.groupby(MAP) i = 0 for k,g in gr: lg = len(list(g)) if k==0 and lg==2: print(2,i) MAP[i]=1 MAP[i+1]=1 break i+=lg else: gr = itertools.groupby(MAP) i = 0 for k,g in gr: lg = len(list(g)) if k==0 and lg==1: print(2,i) MAP[i]=1 MAP[i+1]=1 break i+=lg t = int(input()) if t!=3: exit() k,x = map(int,input().split()) for i in range(x,x+k): MAP[i]=1