#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmax(T &x, T y) {
  return x < y ? x = y, true : false;
}
template <typename T>
bool chkmin(T &x, T y) {
  return x > y ? x = y, true : false;
}
int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const double eps = 1e-12;
int n;
long long x1[5], x2[5], dmytsdy[5], y2[5];
long long dist(pair<long long, long long> x, pair<long long, long long> y) {
  return (x.first - y.first) * (x.first - y.first) +
         (x.second - y.second) * (x.second - y.second);
}
pair<long long, long long> getp(int i, int j) {
  if (x1[i] == x2[i] && x1[j] == x2[j]) {
    return make_pair(1 << 30, 1 << 30);
  }
  if (x1[i] == x2[i]) {
    if (x1[j] == x1[i]) {
      if (dmytsdy[j] < min(dmytsdy[i], y2[i]) ||
          dmytsdy[j] > max(dmytsdy[i], y2[i]))
        return make_pair(1 << 30, 1 << 30);
      return make_pair(x1[i], dmytsdy[j]);
    } else if (x2[j] == x1[i]) {
      if (y2[j] < min(dmytsdy[i], y2[i]) || y2[j] > max(dmytsdy[i], y2[i]))
        return make_pair(1 << 30, 1 << 30);
      return make_pair(x1[i], y2[j]);
    } else
      return make_pair(1 << 30, 1 << 30);
  }
  if (x1[j] == x2[j]) {
    if (x1[i] == x1[j]) {
      if (dmytsdy[i] < min(dmytsdy[j], y2[j]) ||
          dmytsdy[i] > max(dmytsdy[j], y2[j]))
        return make_pair(1 << 30, 1 << 30);
      return make_pair(x1[j], dmytsdy[i]);
    } else if (x2[i] == x1[j]) {
      if (y2[i] < min(dmytsdy[j], y2[j]) || y2[i] > max(dmytsdy[j], y2[j]))
        return make_pair(1 << 30, 1 << 30);
      return make_pair(x1[j], y2[i]);
    } else
      return make_pair(1 << 30, 1 << 30);
  }
  long double k1 = (y2[i] - dmytsdy[i]),
              b1 = (x2[i] * dmytsdy[i] - x1[i] * y2[i]);
  if (k1 * x1[j] + b1 != dmytsdy[j] * (x2[i] - x1[i]) &&
      k1 * x2[j] + b1 != y2[j] * (x2[i] - x1[i]))
    return make_pair(1 << 30, 1 << 30);
  if (k1 * x1[j] + b1 == dmytsdy[j] * (x2[i] - x1[i])) {
    if (x1[j] < min(x1[i], x2[i]) || x1[j] > max(x1[i], x2[i]) ||
        dmytsdy[j] < min(dmytsdy[i], y2[i]) ||
        dmytsdy[j] > max(dmytsdy[i], y2[i]))
      return make_pair(1 << 30, 1 << 30);
    return make_pair(x1[j], dmytsdy[j]);
  } else {
    if (x2[j] < min(x1[i], x2[i]) || x2[j] > max(x1[i], x2[i]) ||
        y2[j] < min(dmytsdy[i], y2[i]) || y2[j] > max(dmytsdy[i], y2[i]))
      return make_pair(1 << 30, 1 << 30);
    return make_pair(x2[j], y2[j]);
  }
}
bool getans(int i, int j) {
  if ((x2[i] - x1[i]) * (y2[j] - dmytsdy[j]) -
          (y2[i] - dmytsdy[i]) * (x2[j] - x1[j]) ==
      0)
    return false;
  if ((x2[i] - x1[i]) * (x2[j] - x1[j]) +
          (y2[i] - dmytsdy[i]) * (y2[j] - dmytsdy[j]) <
      0)
    return false;
  int now = 0;
  for (int k = 1; k <= 3; k++)
    if (i != k && j != k) now = k;
  pair<long double, long double> p1 = getp(i, now), p2 = getp(j, now);
  if (p1.first == (1 << 30) || p2.first == (1 << 30)) return false;
  long long dis1 = dist(p1, make_pair(x1[i], dmytsdy[i])),
            dis2 = dist(p1, make_pair(x2[i], y2[i]));
  if (16 * min(dis1, dis2) < max(dis1, dis2)) return false;
  dis1 = dist(p2, make_pair(x1[j], dmytsdy[j])),
  dis2 = dist(p2, make_pair(x2[j], y2[j]));
  if (16 * min(dis1, dis2) < max(dis1, dis2)) return false;
  return true;
}
int main() {
  int T = readint();
  while (T--) {
    for (int i = 1; i <= 3; i++)
      x1[i] = readint(), dmytsdy[i] = readint(), x2[i] = readint(),
      y2[i] = readint();
    for (int i = 1; i <= 3; i++)
      if (x1[i] > x2[i]) swap(x1[i], x2[i]), swap(dmytsdy[i], y2[i]);
    bool fl = 0;
    for (int i = 1; i <= 3; i++) {
      for (int j = i + 1; j <= 3; j++) {
        if (x1[i] == x2[j] && dmytsdy[i] == y2[j]) {
          swap(x1[j], x2[j]), swap(dmytsdy[j], y2[j]);
          if (getans(i, j)) fl = 1;
          swap(x1[j], x2[j]), swap(dmytsdy[j], y2[j]);
        }
        if (x2[i] == x1[j] && y2[i] == dmytsdy[j]) {
          swap(x1[i], x2[i]), swap(dmytsdy[i], y2[i]);
          if (getans(i, j)) fl = 1;
          swap(x1[i], x2[i]), swap(dmytsdy[i], y2[i]);
        }
        if (x2[i] == x2[j] && y2[i] == y2[j]) {
          swap(x1[i], x2[i]), swap(dmytsdy[i], y2[i]), swap(x1[j], x2[j]),
              swap(dmytsdy[j], y2[j]);
          if (getans(i, j)) fl = 1;
          swap(x1[i], x2[i]), swap(dmytsdy[i], y2[i]), swap(x1[j], x2[j]),
              swap(dmytsdy[j], y2[j]);
        }
        if (x1[i] == x1[j] && dmytsdy[i] == dmytsdy[j]) {
          if (getans(i, j)) fl = 1;
        }
      }
    }
    if (fl)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
