#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
freopen("C.in","r",stdin);
freopen("C.out","w",stdout);
int n; cin >> n;
int a[6];
for (int i =0; i<n; ++i)
{
bool f=false;
for (int j=0;j<6;j++)
{
cin>>a[j];
}  
for (int j=0;j<6;j++)
{
for (int k=0;k<6;k++)
{
if (j%2==1)
{
if ((j-k!=1)&&(j!=k))
{
if (a[k]==a[j]) f=true;
}
}
if (j%2==0)
{
if ((k-j!=1)&&(j!=k))
{
if (a[k]==a[j]) f=true;
}

}
}

}
if (f) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}