#include <bits/stdc++.h>
using namespace std;
long long T;
struct data {
  long long x, y, z, zz;
} a[10];
long long x, y, m, n, p, q, c1, c2;
long long x1, x2, y2, yy;
bool pt;
long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = (s << 1) + (s << 3) + ch - '0';
    ch = getchar();
  }
  return s * w;
}
bool judge(long long x, long long y, long long _x, long long _y, long long __x,
           long long __y) {
  if (((_x - x) * (__x - x) + (_y - y) * (__y - y)) < 0) return 0;
  return 1;
}
bool judge1(long long x, long long y, long long _x, long long _y, long long __x,
            long long __y) {
  if ((__y - y) * (_x - x) == (_y - y) * (__x - x)) return 1;
  return 0;
}
bool judge2(long long x, long long y, long long _x, long long _y, long long __x,
            long long __y) {
  if (x != __x) {
    if (__x > x) {
      if ((__x - x) * 5 < (_x - x)) return 0;
      if ((__x - x) * 5 > (_x - x) * 4) return 0;
      return 1;
    } else {
      if ((x - __x) * 5 < (x - _x)) return 0;
      if ((x - __x) * 5 > (x - _x) * 4) return 0;
      return 1;
    }
  } else {
    if (__y > y) {
      if ((__y - y) * 5 < (_y - y)) return 0;
      if ((__y - y) * 5 > (_y - y) * 4) return 0;
      return 1;
    } else {
      if ((y - __y) * 5 < (y - _y)) return 0;
      if ((y - __y) * 5 > (y - _y) * 4) return 0;
      return 1;
    }
  }
}
int main() {
  cin >> T;
  while (T--) {
    for (long long i = 1; i <= 3; i++)
      a[i].x = read(), a[i].y = read(), a[i].z = read(), a[i].zz = read();
    for (long long i = 1; i <= 2; i++)
      for (long long j = i + 1; j <= 3; j++) {
        if (a[i].x == a[j].x && a[i].y == a[j].y) {
          x = a[i].x, y = a[i].y;
          m = a[i].z, n = a[i].zz;
          p = a[j].z, q = a[j].zz;
          c1 = i;
          c2 = j;
        } else if (a[i].x == a[j].z && a[i].y == a[j].zz) {
          x = a[i].x, y = a[i].y;
          m = a[i].z, n = a[i].zz;
          p = a[j].x, q = a[j].y;
          c1 = i;
          c2 = j;
        } else if (a[i].z == a[j].z && a[i].zz == a[j].zz) {
          x = a[i].z, y = a[i].zz;
          m = a[i].x, n = a[i].y;
          p = a[j].x, q = a[j].y;
          c1 = i;
          c2 = j;
        } else if (a[i].z == a[j].x && a[i].zz == a[j].y) {
          x = a[i].z, y = a[i].zz;
          m = a[i].x, n = a[i].y;
          p = a[j].z, q = a[j].zz;
          c1 = i;
          c2 = j;
        }
      }
    for (long long i = 1; i <= 3; i++)
      if (i != c1 && i != c2) {
        x1 = a[i].x, yy = a[i].y, x2 = a[i].z, y2 = a[i].zz;
        break;
      }
    pt = 1;
    if (judge(x, y, m, n, p, q) == 0) pt = 0;
    if (pt != 0) {
      if (judge1(x, y, m, n, x1, yy) && judge1(x, y, p, q, x2, y2)) {
        if (judge2(x, y, m, n, x1, yy) == 0) pt = 0;
        if (judge2(x, y, p, q, x2, y2) == 0) pt = 0;
      } else if (judge1(x, y, p, q, x1, yy) && judge1(x, y, m, n, x2, y2)) {
        if (judge2(x, y, m, n, x2, y2) == 0) pt = 0;
        if (judge2(x, y, p, q, x1, yy) == 0) pt = 0;
      } else
        pt = 0;
    }
    if (pt == 0)
      puts("NO");
    else
      puts("YES");
  }
  return 0;
}
