//#include<cstdio>
//#include<iostream>
//using namespace std;

#include<stdio.h>

int t,t0,i,j,a[10];

char *ansv[2] = {"NO\n","YES\n"};
char b;

int main()
{
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
	scanf("%d", &t);
	for(t0=0;t0<t;t0++){
		for(i=0;i<6;i++) scanf("%d",&a[i]);
		b=0;
		for(i=0;i<6;i+=2)
			for(j=0;j<6;j+=2)
				if(i!=j){
					b|=a[i]==a[j];
					b|=a[i]==a[j+1];
					b|=a[i+1]==a[j];
					b|=a[i+1]==a[j+1];
					}
		printf(ansv[b]);
		}
	return 0;
}