import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def main(): N = int(input()) if N == 1: print(1,1,flush = True) t = int(input()) return now = [0] * N if N%2 == 0: print(1,2,flush = True) now[1] = 1 else: print(2,2,flush = True) now[1] = 1 now[2] = 1 while True: t = int(input()) if t == 0: return elif t == 1: return elif t >= 2: k,x = map(int,input().split()) if k == 1: now[x - 1] = 1 else: now[x - 1] = 1 now[x] = 1 state = [] cnt = 0 st = 0 for i in range(N): if now[i] == 1: if cnt > 0: state.append((st,cnt)) cnt = 0 st = i + 1 else: cnt += 1 if all(k[1]%2 == 0 for k in state): print(1,state[0][0] + 1,flush = True) else: for s,c in state: if c%2 == 1: print(2,s + 1,flush = True) if __name__ == '__main__': main()