#include <iostream>

using namespace std;

#define PROBLEM "C"

#define MAXN 6

int a[MAXN];

int main() {
	freopen(PROBLEM ".in", "r", stdin);
	freopen(PROBLEM ".out", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		bool yes = false;
		for (int j = 0; j < 6; j++) scanf("%d", &a[j]);
		for (int j = 0; j < 6; j++) {
			int bad;
			if (j & 1) bad = j - 1; else bad = j + 1;
			for (int k = 0; k < 6; k++) {
				if (k != bad && k != j && a[j] == a[k]) {
					yes = true;
					break;
				}
			}
			if (yes) break;
		}
		if (yes) puts("YES"); else puts("NO");
	}
	return 0;
}
