#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>

using namespace std;

bool check(int a, int b, int c, int d, int e, int f) {
	if (a == e) return 1;
	if (a == f) return 1;
	if (a == c) return 1;
	if (a == d) return 1;
	if (b == e) return 1;
	if (b == d) return 1;
	if (b == f) return 1;
	if (b == c) return 1;
	if (c == e) return 1;
	if (c == f) return 1;
	if (d == e) return 1;
	if (d == f) return 1;
	return 0;
}

int main() {
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
	int N;
	scanf("%d",&N);
	for (int i=0; i < N; i++) {
		int a,b,c,d,e,f;
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
		if (check(a,b,c,d,e,f) == 1) printf("YES\n"); else printf("NO\n");
	}

	return 0;
}
