#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int x1[3], y8687969[3], x2[3], y2[3], p[3];
long long dist(long long x1, long long y8687969, long long x2, long long y2) {
  return (x1 - x2) * (x1 - x2) + (y8687969 - y2) * (y8687969 - y2);
}
int ison(long long x1, long long y8687969, long long x2, long long y2,
         long long x3, long long y3) {
  long long vect = (x1 - x2) * (y8687969 - y3) - (y8687969 - y2) * (x1 - x3);
  long long scal = (x1 - x2) * (x1 - x3) + (y8687969 - y2) * (y8687969 - y3);
  return int(vect == 0 && scal < 0);
}
int check(long long x1, long long y8687969, long long x2, long long y2,
          long long x3, long long y3, long long x4, long long y4) {
  if (x1 == x3 && y8687969 == y3)
    ;
  if (x1 == x4 && y8687969 == y4) {
    swap(x3, x4);
    swap(y3, y4);
  }
  if (x2 == x3 && y2 == y3) {
    swap(x1, x2);
    swap(y8687969, y2);
  }
  if (x2 == x4 && y2 == y4) {
    swap(x1, x2);
    swap(y8687969, y2);
    swap(x3, x4);
    swap(y3, y4);
  }
  long long vect = (x1 - x2) * (y3 - y4) - (y8687969 - y2) * (x3 - x4);
  long long scal = (x1 - x2) * (x3 - x4) + (y8687969 - y2) * (y3 - y4);
  return int(vect != 0 && scal >= 0);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    for (int i = 0; i < 3; i++)
      scanf("%d%d%d%d", &x1[i], &y8687969[i], &x2[i], &y2[i]);
    int ok = 0;
    for (int i = 0; i < 3; i++) p[i] = i;
    do {
      int a = p[0], b = p[1], c = p[2];
      if (x1[a] == x1[b] && y8687969[a] == y8687969[b] ||
          x1[a] == x2[b] && y8687969[a] == y2[b] ||
          x2[a] == x2[b] && y2[a] == y2[b] ||
          x2[a] == x1[b] && y2[a] == y8687969[b]) {
        if (check(x1[a], y8687969[a], x2[a], y2[a], x1[b], y8687969[b], x2[b],
                  y2[b]))
          if (ison(x1[c], y8687969[c], x1[a], y8687969[a], x2[a], y2[a]) &&
              ison(x2[c], y2[c], x1[b], y8687969[b], x2[b], y2[b])) {
            long long d1 = dist(x1[a], y8687969[a], x1[c], y8687969[c]);
            long long d2 = dist(x2[a], y2[a], x1[c], y8687969[c]);
            long long d3 = dist(x1[b], y8687969[b], x2[c], y2[c]);
            long long d4 = dist(x2[b], y2[b], x2[c], y2[c]);
            if (min(d1, d2) * 16 >= max(d1, d2) &&
                min(d3, d4) * 16 >= max(d3, d4))
              ok = 1;
          }
      }
    } while (next_permutation(p, p + 3));
    if (ok)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
