import java.io.*;
import java.util.*;

public class Main implements Runnable{
 StreamTokenizer in;
 BufferedReader bin;
 PrintWriter out;
 public static void main(String[] args){
  new Thread(new Main()).start();
 }
 public void run(){
  try{
   bin=new BufferedReader(new FileReader("C.in"));
   in=new StreamTokenizer(bin);
   out=new PrintWriter(new FileWriter("C.out"));
   Locale.setDefault(Locale.US);
   solve();
   out.flush();
  }catch(IOException ex){
   throw new IllegalStateException(ex);
  }
 }
 int nextInt() throws IOException{
  in.nextToken();
  return (int)in.nval;
 }
 void solve() throws IOException{
  int n=nextInt();
  for(int i=0;i<n;i++){
   int a[]=new int[6];
   for(int j=0;j<6;j++)
    a[j]=nextInt();
   if(a[0]==a[2] || a[0]==a[3] ||  a[0]==a[4] ||  a[0]==a[5]){
    out.println("YES");
    continue;
   }
   if(a[1]==a[2] || a[1]==a[3] ||  a[1]==a[4] ||  a[1]==a[5]){
    out.println("YES");
    continue;
   }
   if(a[2]==a[0] || a[2]==a[1] ||  a[2]==a[4] ||  a[2]==a[5]){
    out.println("YES");
    continue;
   }
   if(a[3]==a[0] || a[3]==a[1] ||  a[3]==a[4] ||  a[3]==a[5]){
    out.println("YES");
    continue;
   }
   if(a[4]==a[2] || a[4]==a[3] ||  a[4]==a[0] ||  a[4]==a[1]){
    out.println("YES");
    continue;
   }
   if(a[5]==a[2] || a[5]==a[3] ||  a[5]==a[1] ||  a[5]==a[0]){
    out.println("YES");
    continue;
   }
   out.println("NO");
  }
 }
}