#include <bits/stdc++.h>
using namespace std;
double dot(complex<double> a, complex<double> b) {
  return ((conj(a) * b).real());
}
double cross(complex<double> a, complex<double> b) {
  return ((conj(a) * b).imag());
}
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    complex<double> q[3][2];
    for (int id = 0; id < (int)(3); ++id) {
      double a, b, c, d;
      scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
      q[id][0] = complex<double>(a, b);
      q[id][1] = complex<double>(c, d);
    }
    for (int brid = 0; brid < (int)(3); ++brid) {
      complex<double> p[3][2];
      for (int j = 0; j < (int)(2); ++j) p[2][j] = q[brid][j];
      for (int k = 0; k < (int)(2); ++k)
        for (int j = 0; j < (int)(2); ++j) p[k][j] = q[(brid + 1 + k) % 3][j];
      for (int id = 0; id < (int)(3); ++id)
        if ((abs((p[id][0]) - (p[id][1])) < EPS)) goto NO;
      for (int j = 0; j < (int)(2); ++j)
        for (int k = 0; k < (int)(2); ++k)
          if ((abs((p[0][j]) - (p[1][k])) < EPS)) {
            if (j) swap(p[0][0], p[0][1]);
            if (k) swap(p[1][0], p[1][1]);
            goto COND2;
          }
      goto NO;
    COND2 : {
      double ag = arg((p[1][0] - p[1][1]) / (p[0][0] - p[0][1]));
      ag = abs(ag);
      if (ag > PI) ag = 2 * PI - ag;
      if (ag - PI / 2 > EPS || ag < EPS) goto NO;
      for (int j = 0; j < (int)(2); ++j) {
        if (ccw(p[0][0], p[2][j], p[0][1]) == -2 &&
            ccw(p[1][0], p[2][1 - j], p[1][1]) == -2) {
          double rat1 = abs(p[0][0] - p[2][j]) / abs(p[0][0] - p[0][1]);
          double rat2 = abs(p[1][0] - p[2][1 - j]) / abs(p[1][0] - p[1][1]);
          if (0.2 - rat1 < EPS && rat1 - 0.8 < EPS && 0.2 - rat2 < EPS &&
              rat2 - 0.8 < EPS) {
            puts("YES");
            goto NEXT;
          }
        }
      }
    }
    NO:;
    }
    puts("NO");
  NEXT:;
  }
}
