#include <iostream>

using namespace std;

#define front 0
#define rear 1
#define left 2
#define right 3
#define up 4
#define down 5

int a[6];

int main()
{

  freopen("C.in", "r", stdin);
  freopen("C.out", "w", stdout);

  int n;
  bool res;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    for (int k = 0; k < 6; k++)
      cin >> a[k];
 
   res = false;

   for(int i = 0; i < 6; i++)
     for(int j = i + 2; j < 6; j++)
        if(a[i] == a[j]){
          res = true;
          break;
        }
   
    if(res) cout << "YES";
    else cout << "NO";
    cout << endl;
  }



  return 0;
}