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

#define PROB "C"

using namespace std;

int main() {
  freopen(PROB".in", "r", stdin);
  freopen(PROB".out", "w", stdout);
  int n,i,a,b,c,d,e,f;
  cin >> n;
  for(i=0;i<n;i++) {
    cin >> a>>b>>c>>d>>e>>f;
    string r = "NO";
    if(a==c || a==d || a==e || a==f || b==c || b==d || b==e || b==f || c==e || c==f || d==e || d==f) r="YES";
    cout << r << endl;
  }
  return 0;
}
