import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {

	static final String task = "c";
	
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(new FileReader(task+".in"));
		//BufferedReader in = new BufferedReader(new FileReader(task+".in"));
		PrintWriter out = new PrintWriter(new File(task+".out"));
		
		int n = in.nextInt();
		
		for (int i = 0; i < n; i++){
			int A[] = new int[6];
			boolean Find = false;
			
			for (int j = 0; j < 6; j++) A[j] = in.nextInt();
			
			for (int j = 0; j < 2; j++)
				for (int k = 0; k < 2; k++)
					for (int l = 0; l < 2; l++)
						if (A[j] == A[2+k] || A[j] == A[4+l] || A[2+k] == A[4+l]) Find = true;
			
			if (Find) out.println("YES");
			else out.println("NO");
		} 
		
		in.close();
		out.close();
	}

}
