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