#include <bits/stdc++.h>
using namespace std;
long long dis(long long x, long long y, long long x1, long long y1) {
  return (x - x1) * (x - x1) + (y - y1) * (y - y1);
}
struct node {
  long long x[2], y[2];
} data[3];
int main() {
  int ca;
  cin >> ca;
  while (ca--) {
    bool sign = false;
    for (int i = 0; i < 3; i++)
      cin >> data[i].x[0] >> data[i].y[0] >> data[i].x[1] >> data[i].y[1];
    for (int i = 0; i < 3; i++)
      if (data[i].x[0] == data[i].x[1] && data[i].y[0] == data[i].y[1]) {
        sign = true;
        break;
      }
    if (sign) {
      cout << "NO" << endl;
      continue;
    }
    sign = false;
    int flagi = 0, flagj = 0;
    int signi = 0, signj = 0;
    long long xt, yt;
    for (int i = 0; i < 3; i++)
      for (int k = i + 1; k < 3; k++)
        for (int j = 0; j < 2; j++)
          for (int l = 0; l < 2; l++) {
            if (data[i].x[j] == data[k].x[l] && data[i].y[j] == data[k].y[l]) {
              if (!sign) {
                flagi = i, flagj = k;
                signi = j, signj = l;
                xt = data[i].x[j], yt = data[i].y[j];
                sign = true;
              } else
                sign = false;
            }
          }
    if (!sign) {
      cout << "NO" << endl;
      continue;
    }
    sign = false;
    long long a = xt, b = yt, c = data[flagi].x[signi ^ 1],
              d = data[flagi].y[signi ^ 1], e = data[flagj].x[signj ^ 1],
              f = data[flagj].y[signj ^ 1];
    int flagk;
    long long g, h, m, n;
    for (int i = 0; i < 3; i++)
      if (i != flagi && i != flagj) {
        flagk = i;
        break;
      }
    for (int i = 0; i < 2; i++) {
      if (((data[flagk].x[i] - a) * (d - b) ==
           (data[flagk].y[i] - b) * (c - a)) &&
          ((data[flagk].x[i ^ 1] - a) * (f - b) ==
           (data[flagk].y[i ^ 1] - b) * (e - a))) {
        g = data[flagk].x[i], h = data[flagk].y[i], m = data[flagk].x[i ^ 1],
        n = data[flagk].y[i ^ 1];
        sign = true;
        break;
      }
    }
    if (((g < min(a, c) || g > max(a, c)) ||
         (h < min(b, d) || h > max(b, d))) ||
        ((m < min(a, e) || m > max(a, e)) ||
         (n < min(b, f) || n > max(b, f)))) {
      cout << "NO" << endl;
      continue;
    }
    if (g == m && h == n) sign = false;
    if ((abs((g - m) * (d - b)) == abs((h - n) * (c - a))) ||
        (abs((g - m) * (f - b)) == abs((h - n) * (e - a))))
      sign = false;
    if (!sign) {
      cout << "NO" << endl;
      continue;
    }
    sign = false;
    if (dis(a, b, c, d) + dis(a, b, e, f) >= dis(c, d, e, f)) {
      long long minedge[2], maxedge[2];
      if (dis(g, h, a, b) > dis(g, h, c, d)) {
        minedge[0] = dis(g, h, c, d);
        maxedge[0] = dis(g, h, a, b);
      } else {
        minedge[0] = dis(g, h, a, b);
        maxedge[0] = dis(g, h, c, d);
      }
      if (dis(m, n, a, b) > dis(m, n, e, f)) {
        minedge[1] = dis(m, n, e, f);
        maxedge[1] = dis(m, n, a, b);
      } else {
        minedge[1] = dis(m, n, a, b);
        maxedge[1] = dis(m, n, e, f);
      }
      if (minedge[0] * 16 >= maxedge[0] && minedge[1] * 16 >= maxedge[1])
        sign = true;
    }
    if (sign)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
