#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
void __never(int a) { printf("\nOPS %d", a); }
struct T {
  long long x, y;
  T(long long xx = 0, long long yy = 0) {
    x = xx;
    y = yy;
  }
};
T X[10];
int P[6][3] = {{0, 2, 4}, {2, 0, 4}, {0, 4, 2},
               {4, 0, 2}, {4, 2, 0}, {2, 4, 0}};
long long dist2(T t1, T t2) {
  return (t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y);
}
long long vec(T t1, T t2, T t3) {
  return (t1.x - t3.x) * (t2.y - t3.y) - (t1.y - t3.y) * (t2.x - t3.x);
}
bool check(T a1, T a2, T b1, T b2, T c1, T c2) {
  if (a1.x == b1.x && a1.y == b1.y) {
    long long A = dist2(a2, a1);
    long long B = dist2(b2, b1);
    long long C = dist2(a2, b2);
    long long pr =
        (a2.x - a1.x) * (b2.x - b1.x) + (a2.y - a1.y) * (b2.y - b1.y);
    if ((A + B - C > 0 || pr == 0) && vec(a1, a2, b2) != 0)
      if ((((a1.x) < (a2.x)) ? a1.x : a2.x) <= c1.x &&
          c1.x <= (((a1.x) > (a2.x)) ? a1.x : a2.x))
        if ((((a1.y) < (a2.y)) ? a1.y : a2.y) <= c1.y &&
            c1.y <= (((a1.y) > (a2.y)) ? a1.y : a2.y))
          if ((((b1.x) < (b2.x)) ? b1.x : b2.x) <= c2.x &&
              c2.x <= (((b1.x) > (b2.x)) ? b1.x : b2.x))
            if ((((b1.y) < (b2.y)) ? b1.y : b2.y) <= c2.y &&
                c2.y <= (((b1.y) > (b2.y)) ? b1.y : b2.y))
              if (vec(a1, a2, c1) == 0 && vec(b1, b2, c2) == 0) {
                long long x1 = dist2(a1, c1);
                long long x2 = dist2(a2, c1);
                long long y1 = dist2(b1, c2);
                long long y2 = dist2(b2, c2);
                if (x1 * (long long)16 >= x2 && x2 * (long long)16 >= x1)
                  if (y1 * (long long)16 >= y2 && y2 * (long long)16 >= y1)
                    return true;
              }
  }
  return false;
}
void sol() {
  for (int a = (0); a <= (7); a++) {
    bool f1 = ((a & 1) == 1);
    bool f2 = (((a >> 1) & 1) == 1);
    bool f3 = (((a >> 2) & 1) == 1);
    for (int b = (0); b <= (5); b++)
      if (check(f1 ? X[P[b][0]] : X[P[b][0] + 1],
                f1 ? X[P[b][0] + 1] : X[P[b][0]],
                f2 ? X[P[b][1]] : X[P[b][1] + 1],
                f2 ? X[P[b][1] + 1] : X[P[b][1]],
                f3 ? X[P[b][2]] : X[P[b][2] + 1],
                f3 ? X[P[b][2] + 1] : X[P[b][2]])) {
        printf("YES\n");
        return;
      }
  }
  printf("NO\n");
}
int main() {
  int t, x, y;
  scanf("%d", &t);
  for (int a = (1); a <= (t); a++) {
    for (int b = (0); b <= (5); b++) {
      scanf("%d%d", &x, &y);
      X[b] = T(x, y);
    }
    sol();
  }
  return 0;
}
