T = int(input()) for _ in range(T): H,W = list(map(int,input().split())) Qx,Qy = 1,1 x,y = list(map(int,input().split())) # 横を塞ぐ if(y != 2): Qy = y-1 print(Qx,Qy) x,y = list(map(int,input().split())) # 目の前まで行く Qx = x print(Qx,Qy) # 相手下がるしかない x,y = list(map(int,input().split())) if not (x == y == 0): print(x,y-1) list(map(int,input().split()))