#include <bits/stdc++.h>
using namespace std;
namespace std {
bool operator<(const complex<double>& a, const complex<double>& b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}  // namespace std
inline double dot(complex<double> a, complex<double> b) {
  return real(conj(a) * b);
}
inline double cross(complex<double> a, complex<double> b) {
  return imag(conj(a) * b);
}
const double PI = acos(-1);
const double EPS = 1e-12;
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > EPS) return +1;
  if (cross(b, c) < -EPS) return -1;
  if (dot(b, c) < -EPS) return +2;
  if (norm(b) + EPS < norm(c)) return -2;
  return 0;
}
bool IsIntersectSS(complex<double> a1, complex<double> a2, complex<double> b1,
                   complex<double> b2) {
  return ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0;
}
double arg(complex<double> a, complex<double> b) { return arg(a / b); }
complex<double> IntersectionLL(complex<double> a1, complex<double> a2,
                               complex<double> b1, complex<double> b2) {
  complex<double> a = a2 - a1;
  complex<double> b = b2 - b1;
  return a1 + a * cross(b, b1 - a1) / cross(b, a);
}
bool bunkatu(pair<complex<double>, complex<double> > s,
             pair<complex<double>, complex<double> > t) {
  complex<double> p = IntersectionLL(s.first, s.second, t.first, t.second);
  double len1 = abs(s.first - p);
  double len2 = abs(s.second - p);
  if (len1 > len2) swap(len1, len2);
  double r = len1 / (len1 + len2);
  return 1.0 / 5 - EPS <= r;
}
bool IsIntersectSP(complex<double> a, complex<double> b, complex<double> c) {
  return (abs(a - c) + abs(c - b) < abs(a - b) + EPS);
}
bool IsTouch(pair<complex<double>, complex<double> > s,
             pair<complex<double>, complex<double> > t) {
  complex<double> p = IntersectionLL(s.first, s.second, t.first, t.second);
  if (abs(t.first - p) < EPS) return true;
  if (abs(t.second - p) < EPS) return true;
  return false;
}
bool check(pair<complex<double>, complex<double> > seg[]) {
  if (!(seg[0].first == seg[1].first || seg[0].first == seg[1].second ||
        seg[0].second == seg[1].first || seg[0].second == seg[1].second)) {
    return false;
  }
  if (seg[0].second == seg[1].first || seg[0].second == seg[1].second) {
    swap(seg[0].first, seg[0].second);
  }
  if (seg[0].first == seg[1].second) swap(seg[1].first, seg[1].second);
  assert(seg[0].first == seg[1].first);
  double thete =
      arg(seg[0].second - seg[0].first, seg[1].second - seg[1].first);
  if (!(EPS < thete && thete < PI / 2 + EPS)) return false;
  if (!IsIntersectSS(seg[0].first, seg[0].second, seg[2].first,
                     seg[2].second) ||
      !IsIntersectSS(seg[1].first, seg[1].second, seg[2].first, seg[2].second))
    return false;
  if (!IsTouch(seg[0], seg[2]) || !IsTouch(seg[1], seg[2])) return false;
  if (!bunkatu(seg[0], seg[2]) || !bunkatu(seg[1], seg[2])) return false;
  return true;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    pair<complex<double>, complex<double> > seg[3];
    for (int i = 0; i < (int)(3); ++i) {
      int x, y, z, w;
      cin >> x >> y >> z >> w;
      seg[i] = make_pair(complex<double>(x, y), complex<double>(z, w));
    }
    bool ok = false;
    sort(seg, seg + 3);
    do {
      pair<complex<double>, complex<double> > clone[3];
      for (int i = 0; i < (int)(3); ++i) clone[i] = seg[i];
      if (check(clone)) {
        ok = true;
        break;
      }
    } while (next_permutation(seg, seg + 3));
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}
