#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int NMAX = 1e4;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
int tests;
vector<pair<pair<int, int>, pair<int, int> > > v;
int p[3];
inline bool onSite(pair<pair<int, int>, pair<int, int> > A,
                   pair<int, int> fir) {
  long long a = A.second.second - A.first.second,
            b = A.first.first - A.second.first,
            c = -(A.first.first * 1ll * a + A.first.second * 1ll * b);
  long long t = a * fir.first + b * fir.second + c;
  if (t != 0) return false;
  long long minx = A.first.first, maxx = A.second.first;
  if (minx > maxx) swap(minx, maxx);
  long long miny = A.first.second, maxy = A.second.second;
  if (miny > maxy) swap(miny, maxy);
  long long x = fir.first, y = fir.second;
  if (x < minx || x > maxx) return false;
  if (y < miny || y > maxy) return false;
  return true;
}
inline long long dist(pair<int, int> fir, pair<int, int> sec) {
  int ax = fir.first - sec.first;
  int ay = fir.second - sec.second;
  long long t1 = ax * 1ll * ax;
  long long t2 = ay * 1ll * ay;
  return t1 + t2;
}
inline double ang(pair<pair<int, int>, pair<int, int> > &A,
                  pair<pair<int, int>, pair<int, int> > &B) {
  long long a1 = A.second.second - A.first.second,
            b1 = A.first.first - A.second.first;
  long long a2 = B.second.second - B.first.second,
            b2 = B.first.first - B.second.first;
  long long det = a1 * b2 - a2 * b1;
  if (det == 0) return 0;
  double fir = sqrt(dist(A.first, A.second) + 0.0);
  double sec = sqrt(dist(B.first, B.second) + 0.0);
  double thir = sqrt(dist(A.second, B.second) + 0.0);
  double an = acos((((thir) * (thir)) - ((fir) * (fir)) - ((sec) * (sec))) /
                   (-2.0 * fir * sec));
  return an;
}
bool check(pair<pair<int, int>, pair<int, int> > a,
           pair<pair<int, int>, pair<int, int> > b,
           pair<pair<int, int>, pair<int, int> > c) {
  pair<int, int> a1 = a.first, a2 = a.second;
  pair<int, int> b1 = b.first, b2 = b.second;
  pair<int, int> c1 = c.first, c2 = c.second;
  if (a1.first != b1.first || a1.second != b1.second) return false;
  if (!onSite(a, c1) || !onSite(b, c2)) return false;
  double an = ang(a, b);
  if (fabs(an) < EPS || an - EPS > PI / 2.0) return false;
  pair<int, int> f1 = c1, f2 = c2;
  long long d1 = dist(f1, a1), d2 = dist(f1, a2);
  if (d1 > d2) swap(d1, d2);
  if (d1 * 16 < d2) return false;
  d1 = dist(f2, b1), d2 = dist(f2, b2);
  if (d1 > d2) swap(d1, d2);
  if (d1 * 16 < d2) return false;
  return true;
}
int main() {
  cin >> tests;
  while (tests > 0) {
    tests--;
    v.clear();
    for (int i = 0; i < int(3); i++) {
      int ax, ay, bx, by;
      scanf("%d%d%d%d", &ax, &ay, &bx, &by);
      v.push_back(make_pair(make_pair(ax, ay), make_pair(bx, by)));
      p[i] = i;
    }
    bool ok = false;
    do {
      for (int i = 0; i < int(8); i++) {
        pair<int, int> fir1 = v[p[0]].first, fir2 = v[p[0]].second;
        if (i & 1) swap(fir1, fir2);
        pair<int, int> sec1 = v[p[1]].first, sec2 = v[p[1]].second;
        if (i & 2) swap(sec1, sec2);
        pair<int, int> thir1 = v[p[2]].first, thir2 = v[p[2]].second;
        if (i & 4) swap(thir1, thir2);
        if (check(make_pair(fir1, fir2), make_pair(sec1, sec2),
                  make_pair(thir1, thir2))) {
          ok = true;
          break;
        }
      }
    } while (next_permutation(p, p + 3));
    if (ok)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
