#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
struct pt {
  double x, y;
  pt(){};
  pt(double x, double y) : x(x), y(y){};
};
struct seg {
  pt u, v;
  seg(){};
  seg(pt u, pt v) : u(u), v(v){};
};
inline bool eq(pt u, pt v) {
  return fabs(u.x - v.x) < EPS && fabs(u.y - v.y) < EPS;
}
inline double sqr(double x) { return x * x; }
inline double dist(pt& p1, pt& p2) {
  return sqrt(sqr(p1.x - p2.x) + sqr(p1.y - p2.y));
}
inline double scalarProduct(pt v1, pt v2) { return v1.x * v2.x + v1.y * v2.y; }
inline double vectorProduct(pt v1, pt v2) { return v1.x * v2.y - v1.y * v2.x; }
double relat(double a, double b) { return min(a, b) / max(a, b); }
bool solve(vector<seg>& s) {
  seg s1, s2, s3;
  bool fd = false;
  for (int i = 0; i < s.size() && !fd; ++i)
    for (int j = i + 1; j < s.size(); ++j)
      if (eq(s[i].u, s[j].u)) {
        fd = true;
        s1 = s[i];
        s2 = s[j];
        for (int t = 0; t < int(s.size()); ++t)
          if (t != i && t != j) s3 = s[t];
        break;
      } else if (eq(s[i].u, s[j].v)) {
        fd = true;
        swap(s[j].v, s[j].u);
        s1 = s[i];
        s2 = s[j];
        for (int t = 0; t < int(s.size()); ++t)
          if (t != i && t != j) s3 = s[t];
        break;
      } else if (eq(s[i].v, s[j].v)) {
        fd = true;
        s1 = s[i];
        s2 = s[j];
        swap(s[i].u, s[i].v);
        swap(s[j].u, s[j].v);
        for (int t = 0; t < int(s.size()); ++t)
          if (t != i && t != j) s3 = s[t];
        break;
      } else if (eq(s[i].v, s[j].u)) {
        fd = true;
        swap(s[i].u, s[i].v);
        s1 = s[i];
        s2 = s[j];
        for (int t = 0; t < int(s.size()); ++t)
          if (t != i && t != j) s3 = s[t];
        break;
      }
  if (!fd) return false;
  pt v1(s1.v.x - s1.u.x, s1.v.y - s1.u.y), v2(s2.v.x - s2.u.x, s2.v.y - s2.u.y);
  if (fabs(vectorProduct(v1, v2)) > EPS &&
      (scalarProduct(v1, v2) > EPS || fabs(scalarProduct(v1, v2)) < EPS)) {
    pt v3(s3.u.x - s1.u.x, s3.u.y - s1.u.y),
        v4(s3.u.x - s1.v.x, s3.u.y - s1.v.y);
    if (!(fabs(vectorProduct(v3, v4)) < EPS && scalarProduct(v3, v4) < EPS)) {
      swap(s3.u, s3.v);
    }
    v3 = pt(s3.u.x - s1.u.x, s3.u.y - s1.u.y);
    v4 = pt(s3.u.x - s1.v.x, s3.u.y - s1.v.y);
    if (!(fabs(vectorProduct(v3, v4)) < EPS && scalarProduct(v3, v4) < EPS)) {
      return false;
    }
    swap(s3.u, s3.v);
    v3 = pt(s3.u.x - s2.u.x, s3.u.y - s2.u.y);
    v4 = pt(s3.u.x - s2.v.x, s3.u.y - s2.v.y);
    if (!(fabs(vectorProduct(v3, v4)) < EPS && scalarProduct(v3, v4) < EPS)) {
      return false;
    }
    double relat1 = relat(dist(s1.u, s3.v), dist(s1.v, s3.v));
    if (relat1 < 1 / 4. - EPS) return false;
    double relat2 = relat(dist(s2.u, s3.u), dist(s2.v, s3.u));
    if (relat2 < 1 / 4. - EPS) return false;
    return true;
  } else
    return false;
}
int main() {
  vector<seg> s(3);
  int t;
  scanf("%d", &t);
  for (int it = 0; it < int(t); ++it) {
    for (int i = 0; i < int(3); ++i) {
      int x, y, z, w;
      scanf("%d%d%d%d", &x, &y, &z, &w);
      s[i] = seg(pt(x, y), pt(z, w));
    }
    if (solve(s))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
