package Main;

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

public class Main {
	public static boolean ckk(int r, int s, int t){
		if(r == s&&s == t&&r == t){return true;}
		return false;
	}
	public static void main(String[] args) throws Exception{
		Scanner in = new Scanner(new FileReader("C.in"));
		PrintWriter out = new PrintWriter("C.out");
		int n = in.nextInt();
		int a, b, c, d, e, f;
		for(int g=0; g<n; g++){
			boolean res = false;
			a = in.nextInt();
			c = in.nextInt();
			b = in.nextInt();
			d = in.nextInt();
			e = in.nextInt();
			f = in.nextInt();
			
			if(a == b||a == e||a==d||a==f||b==e||b==c||b==f){
				res = true;
			}
			if(c==e||c==d||c==f||d==e||d==f){
				res = true;
			}
			if(ckk(a,b,e)||ckk(a,b,f)||ckk(a,d,f)||ckk(a,d,e)||ckk(b,c,f)||ckk(b,c,f)||ckk(c,d,f)||ckk(c,d,e)){
				res = true;
			}
			
			if(res){
				out.println("YES");
			}
			else{
				out.println("NO");
			}
		}
		out.close();
	}
}
