n=int(input()) for i in range(n): _,w,*_=map(int,input().split()) _,y,*_=map(int,input().split()) input() print("Yes" if w>0 and y<1 else "No")