#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
using namespace std;
struct liuyifan_data {
  int x, y, z, zz;
} a[10];
int t, x, y, m, n, p, q, x1, liuifan_y1, x2, y2, c1, c2, flag;
inline int pd1(int a, int b, int c, int d, int e, int f) {
  if ((long long)(f - b) * (c - a) == (long long)(d - b) * (e - a)) return 1;
  return 0;
}
inline int pd2(int x, int y, int a, int b, int p, int q) {
  if ((long long)(a - x) * (p - x) + (long long)(b - y) * (q - y) < 0) return 0;
  return 1;
}
inline int pd3(int x, int y, int m, int n, int a, int b) {
  if (x != a) {
    if (a > x) {
      if ((a - x) * 5 < (m - x)) return 0;
      if ((a - x) * 5 > (m - x) * 4) return 0;
      return 1;
    } else {
      if ((x - a) * 5 < (x - m)) return 0;
      if ((x - a) * 5 > (x - m) * 4) return 0;
      return 1;
    }
  } else {
    if (b > y) {
      if ((b - y) * 5 < (n - y)) return 0;
      if ((b - y) * 5 > (n - y) * 4) return 0;
      return 1;
    } else {
      if ((y - b) * 5 < (y - n)) return 0;
      if ((y - b) * 5 > (y - n) * 4) return 0;
      return 1;
    }
  }
}
int main() {
  while (scanf("%d", &t) == 1) {
    while (t--) {
      for (register int i = 1; i <= 3; i++)
        scanf("%d%d%d%d", &a[i].x, &a[i].y, &a[i].z, &a[i].zz);
      for (register int i = 1; i <= 2; i++)
        for (register int 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 (register int i = 1; i <= 3; i++)
        if (i != c1 && i != c2) {
          x1 = a[i].x, liuifan_y1 = a[i].y, x2 = a[i].z, y2 = a[i].zz;
          break;
        }
      flag = 1;
      if (pd2(x, y, m, n, p, q) == 0) flag = 0;
      if (flag) {
        if (pd1(x, y, m, n, x1, liuifan_y1) && pd1(x, y, p, q, x2, y2)) {
          if (pd3(x, y, m, n, x1, liuifan_y1) == 0) flag = 0;
          if (pd3(x, y, p, q, x2, y2) == 0) flag = 0;
        } else if (pd1(x, y, p, q, x1, liuifan_y1) && pd1(x, y, m, n, x2, y2)) {
          if (pd3(x, y, m, n, x2, y2) == 0) flag = 0;
          if (pd3(x, y, p, q, x1, liuifan_y1) == 0) flag = 0;
        } else
          flag = 0;
      }
      puts(flag ? "YES" : "NO");
    }
  }
  return 0;
}
