#include<iostream>
#include<vector>
using namespace std;

int main() {
freopen("C.in","r",stdin);
freopen("C.out","w",stdout);
int a,b;
vector<vector<int> > vec;
vector<int>vec2;
cin>>b;

for(int i=0; i < b; i++)
  {  
     for (int j=0; j<6; j++ )
     	{
     	 cin >> a;
     	 vec2.push_back(a);
         
         }
	vec.push_back(vec2);
      vec2.clear();  

        }
        


for(int i=0; i < b; i++)
  {  
          if(vec[i][0]==vec[i][2]||vec[i][0]==vec[i][3]||vec[i][0]==vec[i][4]||vec[i][0]==vec[i][5] ) { cout << "YES"<<endl;continue; }
      	  else if(vec[i][1]==vec[i][3]||vec[i][1]==vec[i][4]||vec[i][1]==vec[i][5]||vec[i][1]==vec[i][2]) { cout << "YES"<<endl; continue; }
      	   else if(vec[i][2]==vec[i][4]||vec[i][2]==vec[i][5]) { cout << "YES"<<endl; continue; }
      	   else if(vec[i][3]==vec[i][5]||vec[i][3]==vec[i][4]) { cout << "YES"<<endl; continue; }
           else { cout<<"NO"<<endl; continue;}
     	          
        }



return 0;
}