#include <bits/stdc++.h>
struct P {
  long long x, y;
  P(long long x = 0, long long y = 0) : x(x), y(y) {}
  double len() { return sqrt(1.0 * (x * x + y * y)); }
};
int sgn(long long x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }
bool operator==(P a, P b) { return a.x == b.x && a.y == b.y; }
P operator+(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator-(P a, P b) { return P(a.x - b.x, a.y - b.y); }
long long dot(P a, P b) { return a.x * b.x + a.y * b.y; }
long long det(P a, P b) { return a.x * b.y - a.y * b.x; }
P A[10], W[10];
bool ok(P a, P b, P c) {
  return sgn(det(c - b, c - a)) == 0 && sgn(dot(c - b, c - a)) != 1 &&
         (c - a).len() * 5 > (a - b).len() - 1e-9 &&
         (c - b).len() * 5 > (a - b).len() - 1e-9;
}
bool sharp(P a, P b, P c) {
  return sgn(det(a - b, a - c)) != 0 &&
         dot(b - a, c - a) / (a - b).len() / (a - c).len() > -1e-9;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T-- > 0) {
    for (int i = 0; i < 6; ++i) {
      scanf("%I64d%I64d", &A[i].x, &A[i].y);
    }
    int endx = 0, endy = 0;
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 6; j++) {
        if (i / 2 != j / 2 && A[i] == A[j]) {
          endx = i, endy = j;
          break;
        }
      }
    }
    W[0] = A[endx];
    W[1] = A[endx / 2 * 4 + 1 - endx];
    W[2] = A[endy / 2 * 4 + 1 - endy];
    int w = (3 - endx / 2 - endy / 2) * 2;
    if ((sharp(W[0], W[1], W[2])) &&
        (ok(W[0], W[1], A[w]) && ok(W[0], W[2], A[w + 1]) ||
         ok(W[0], W[1], A[w + 1]) && ok(W[0], W[2], A[w])))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
