#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
long long x1[3], y47824262[3], x2[3], y2[3];
long long xx1[3], yy1[3], xx2[3], yy2[3];
long long cross(long long x1, long long y47824262, long long x2, long long y2) {
  return x1 * x2 + y47824262 * y2;
}
long long dot(long long x1, long long y47824262, long long x2, long long y2) {
  return x1 * y2 - x2 * y47824262;
}
double dist(long long x1, long long y47824262, long long x2, long long y2) {
  return sqrt((((double)x2 - x1) * ((double)x2 - x1)) +
              (((double)y2 - y47824262) * ((double)y2 - y47824262)));
}
double getp(long long x1, long long y47824262, long long x2, long long y2,
            long long x, long long y) {
  if (dot(x2 - x1, y2 - y47824262, x - x1, y - y47824262)) return -1;
  double p = (double)dist(x, y, x1, y47824262) / (double)dist(x, y, x2, y2);
  if (dist(x, y, x1, y47824262) > dist(x1, y47824262, x2, y2)) return -1;
  if (dist(x, y, x2, y2) > dist(x1, y47824262, x2, y2)) return -1;
  return p;
}
int check() {
  if (x1[0] != x1[1] || y47824262[0] != y47824262[1]) return 0;
  if (cross(x2[0] - x1[0], y2[0] - y47824262[0], x2[1] - x1[1],
            y2[1] - y47824262[1]) < 0)
    return 0;
  double p1 = getp(x1[0], y47824262[0], x2[0], y2[0], x1[2], y47824262[2]);
  double p2 = getp(x1[1], y47824262[1], x2[1], y2[1], x2[2], y2[2]);
  if (p1 < 1 / 4.0 || p1 > 4.0) return 0;
  if (p2 < 1 / 4.0 || p2 > 4.0) return 0;
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int u = (0); u < (n); u++) {
    for (int j = (0); j < (3); j++) cin >> xx1[j] >> yy1[j] >> xx2[j] >> yy2[j];
    int p[3];
    for (int i = (0); i < (3); i++) p[i] = i;
    int f = 0;
    do {
      for (int mask = (0); mask < ((1 << 3)); mask++) {
        for (int i = (0); i < (3); i++) {
          x1[i] = xx1[p[i]];
          x2[i] = xx2[p[i]];
          y47824262[i] = yy1[p[i]];
          y2[i] = yy2[p[i]];
        }
        for (int i = (0); i < (3); i++)
          if (mask & (1 << i)) {
            swap(x1[i], x2[i]);
            swap(y47824262[i], y2[i]);
          }
        if (check()) {
          f = 1;
          break;
        }
      }
    } while (next_permutation(p, p + 3));
    if (f)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
