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

public class Main {
    public static void main(String[] args) {
        try {
            PrintWriter out = null;
            Scanner in = new Scanner(new FileReader("C.in"));
            int n = 0;
            n = in.nextInt();
            int word[] = new int[n];
            int[][] kub = new int[n][6];
            for (int i = 0; i < n; i++) 
                for (int j = 0; j < 6; j++) 
                    kub[i][j] = in.nextInt();
            in.close();
            for (int i=0; i<kub.length; i++){
                for (int j=0; j<6; j++){
                    if (j%2==0){
                        for (int k=j+2; k<6; k++){
                            if (kub[i][j]==kub[i][k]){
                                word[i] = 1;
                                break;
                            }
                            else{
                                word[i] = 0;
                                continue;
                            }
                        }
                        if (word[i]==1){
                            break;
                        }
                        else if (word[i]==0){
                            continue;
                        }
                    }
                    else{
                        for (int k=j+1; k<6; k++){
                            if (kub[i][j]==kub[i][k]){
                                word[i] = 1;
                                break;
                            }
                            else{
                                word[i] = 0;
                                continue;
                            }
                        }
                        if (word[i]==1){
                            break;
                        }
                        else if (word[i]==0){
                            continue;
                        }
                    }                        
                }
            }
            out = new PrintWriter(new FileWriter("C.out"));
            for (int i=0; i<n; i++){
                if (word[i]==1)
                    out.println("YES");
                else
                    out.println("NO");
            }
            out.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
