#include <stdio.h>
long k,n,c,x,y;
long m[7];
int check () {
 int i=0,j=0;
 for (i=0;i<6;i++) {
  if(i<2) {
   for (j=2;j<6;j++) {
    if (m[i] == m[j]) return 1;
   
   }
  }
  else if(i<4) {
   if (m[i] == m[0]) return 1;
   if (m[i] == m[1]) return 1;
   if (m[i] == m[4]) return 1;
   if (m[i] == m[5]) return 1;
  } else {
   for (j=0;j<4;j++) {
    if (m[i] == m[j]) return 1;
   }   
  }
 }
return 0;
}
int main() {
freopen ("c.in","r",stdin);
freopen ("c.out","w",stdout);
scanf("%ld", &n);
for(k=0;k<n;k++) {
 scanf("%ld %ld %ld %ld %ld %ld",&m[0],&m[1],&m[2],&m[3],&m[4],&m[5]);
 printf("%s\n",((check())?"YES":"NO"));
 
 }
return 0;
}
