r=lambda:map(int,input().split()) for _ in[0]*int(input()): r();x,y=r();z=1 if y>2:print(1,z:=y-1);x,y=r() print(x,z);x,y=r() if x:print(x,y-1);r()