#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
		int n;
		int a[6];
		int b[]={1,0,3,2,5,4};
		cin>>n;
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<6;j++)
				cin>>a[j];
			bool h=false;
			for (int i=0;i<6;i++) 
				for (int j=i+1;j<6;j++) {
					if (a[i]==a[j]&&j!=b[i]) h=true;
				}
			if (h) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	return 0;
}