
import java.io.*;
import java.util.*;
class Main{
	static int N=0;
	static boolean b=false;
 
	public static void main(String [] args){
		try {
		Scanner sc= new Scanner(new FileReader("C.in"));
		PrintWriter out = new PrintWriter (new FileWriter ("C.out"));

		N= sc.nextInt();
			int a[][]= new int[N][6];
			for (int i=0;i<N;i++){
				for (int j=0; j<6;j++) {
					a[i][j]= sc.nextInt();
					}
			}
		   for(int i=0;i<N;i++){
  			for (int j=0; j<4;j++) {
                                               if(a[i][j]==a[i][j+2])b=true;}
                                       if(b==false){if((a[i][4]==a[i][0])||(a[i][5]==a[i][1]))b=true;}
                           if(b==false)out.println("NO");else out.println("YES");
b=false;				
	}
			

			sc.close();
	
	out.close();
	} catch (Exception e){}
	}

}