#include <bits/stdc++.h>
int main(void) {
  int i, j, k, l, o, p;
  int no;
  int cox[3][2];
  int coy[3][2];
  long long cex[3];
  long long cey[3];
  long long mix[2];
  long long miy[2];
  int rom[3][3] = {{0, 2, 1}, {2, 0, 0}, {1, 0, 0}};
  scanf("%d", &no);
  int res = 0;
  for (p = 0; p < no; p++) {
    res = 0;
    for (o = 0; o < 3; o++)
      scanf("%d%d%d%d", &cox[o][0], &coy[o][0], &cox[o][1], &coy[o][1]);
    for (i = 0, k = -1; i < 3; i++) {
      for (j = 0; j < 3; j++)
        if (i != j) {
          if (cox[i][0] == cox[j][0] && coy[i][0] == coy[j][0])
            k = 0;
          else if (cox[i][1] == cox[j][1] && coy[i][1] == coy[j][1])
            k = 3;
          else if (cox[i][1] == cox[j][0] && coy[i][1] == coy[j][0])
            k = 2;
          else if (cox[i][0] == cox[j][1] && coy[i][0] == coy[j][1])
            k = 1;
          if (k >= 0) break;
        }
      if (k >= 0) break;
    }
    if (k < 0) {
      res |= 1;
      {
        puts(res ? "NO" : "YES");
        continue;
      };
    }
    cex[0] = (long long)cox[j][k & 1];
    cey[0] = (long long)coy[j][k & 1];
    cex[1] = (long long)cox[i][!(k & 2)];
    cey[1] = (long long)coy[i][!(k & 2)];
    cex[2] = (long long)cox[j][!(k & 1)];
    cey[2] = (long long)coy[j][!(k & 1)];
    k = rom[i][j];
    mix[0] = (long long)cox[k][0];
    mix[1] = (long long)cox[k][1];
    miy[0] = (long long)coy[k][0];
    miy[1] = (long long)coy[k][1];
    if ((cex[1] - cex[0]) * (cex[2] - cex[0]) +
                (cey[1] - cey[0]) * (cey[2] - cey[0]) <
            0 ||
        (cex[1] - cex[0]) * (cey[2] - cey[0]) ==
            (cex[2] - cex[0]) * (cey[1] - cey[0])) {
      res |= 1;
      {
        puts(res ? "NO" : "YES");
        continue;
      };
    }
    for (i = 1; i <= 2; i++)
      if ((cex[i] - cex[0]) * (miy[0] - cey[0]) ==
          (cey[i] - cey[0]) * (mix[0] - cex[0])) {
        {
          if (!((cex[i]) >= (mix[0]) && (mix[0]) >= (cex[0]) ||
                (cex[i]) <= (mix[0]) && (mix[0]) <= (cex[0])))
            res |= 1;
          if ((((cex[i]) - (mix[0])) > 0 ? ((cex[i]) - (mix[0]))
                                         : -((cex[i]) - (mix[0]))) >
                  4 * (((mix[0]) - (cex[0])) > 0 ? ((mix[0]) - (cex[0]))
                                                 : -((mix[0]) - (cex[0]))) ||
              4 * (((cex[i]) - (mix[0])) > 0 ? ((cex[i]) - (mix[0]))
                                             : -((cex[i]) - (mix[0]))) <
                  (((mix[0]) - (cex[0])) > 0 ? ((mix[0]) - (cex[0]))
                                             : -((mix[0]) - (cex[0]))))
            res |= 1;
        };
        {
          if (!((cey[i]) >= (miy[0]) && (miy[0]) >= (cey[0]) ||
                (cey[i]) <= (miy[0]) && (miy[0]) <= (cey[0])))
            res |= 1;
          if ((((cey[i]) - (miy[0])) > 0 ? ((cey[i]) - (miy[0]))
                                         : -((cey[i]) - (miy[0]))) >
                  4 * (((miy[0]) - (cey[0])) > 0 ? ((miy[0]) - (cey[0]))
                                                 : -((miy[0]) - (cey[0]))) ||
              4 * (((cey[i]) - (miy[0])) > 0 ? ((cey[i]) - (miy[0]))
                                             : -((cey[i]) - (miy[0]))) <
                  (((miy[0]) - (cey[0])) > 0 ? ((miy[0]) - (cey[0]))
                                             : -((miy[0]) - (cey[0]))))
            res |= 1;
        };
        break;
      }
    if (i > 2) res |= 1;
    i = i == 2 ? 1 : 2;
    if ((cex[i] - cex[0]) * (miy[1] - cey[0]) !=
        (cey[i] - cey[0]) * (mix[1] - cex[0]))
      res |= 1;
    {
      if (!((cex[i]) >= (mix[1]) && (mix[1]) >= (cex[0]) ||
            (cex[i]) <= (mix[1]) && (mix[1]) <= (cex[0])))
        res |= 1;
      if ((((cex[i]) - (mix[1])) > 0 ? ((cex[i]) - (mix[1]))
                                     : -((cex[i]) - (mix[1]))) >
              4 * (((mix[1]) - (cex[0])) > 0 ? ((mix[1]) - (cex[0]))
                                             : -((mix[1]) - (cex[0]))) ||
          4 * (((cex[i]) - (mix[1])) > 0 ? ((cex[i]) - (mix[1]))
                                         : -((cex[i]) - (mix[1]))) <
              (((mix[1]) - (cex[0])) > 0 ? ((mix[1]) - (cex[0]))
                                         : -((mix[1]) - (cex[0]))))
        res |= 1;
    };
    {
      if (!((cey[i]) >= (miy[1]) && (miy[1]) >= (cey[0]) ||
            (cey[i]) <= (miy[1]) && (miy[1]) <= (cey[0])))
        res |= 1;
      if ((((cey[i]) - (miy[1])) > 0 ? ((cey[i]) - (miy[1]))
                                     : -((cey[i]) - (miy[1]))) >
              4 * (((miy[1]) - (cey[0])) > 0 ? ((miy[1]) - (cey[0]))
                                             : -((miy[1]) - (cey[0]))) ||
          4 * (((cey[i]) - (miy[1])) > 0 ? ((cey[i]) - (miy[1]))
                                         : -((cey[i]) - (miy[1]))) <
              (((miy[1]) - (cey[0])) > 0 ? ((miy[1]) - (cey[0]))
                                         : -((miy[1]) - (cey[0]))))
        res |= 1;
    };
    {
      puts(res ? "NO" : "YES");
      continue;
    };
  }
  exit(0);
}
