
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>

using namespace std;

int n;
int sides[10];

int init_prg() {
   scanf("%d", &n);
   memset(sides,11,sizeof(sides));
   return 0;
}

bool isSame() {
   for (int i = 0; i < 6; ++i)
      if (i&1 > 0) {
         for (int j = i+1; j < 6; ++j)
            if (sides[i] == sides[j])
               return true;
      }
      else {
         for (int j = i+2; j < 6; ++j)
            if (sides[i] == sides[j])
               return true;
      }
   return false;
}

int main() {

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

   init_prg();
   
   for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 6; ++j)
         scanf("%d", &sides[j]);
      if (isSame())
         cout << "YES\n";
      else
         cout << "NO\n";
   }
   
   return 0;
}
