#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Pt {
  T x, y;
  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}
  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }
  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }
  Pt<T> rot90() { return Pt<T>(-y, x); }
  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }
  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};
Pt<double> ps[3][2];
int main() {
  int tn;
  scanf("%d", &tn);
  while (tn--) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 2; j++) scanf("%lf%lf", &ps[i][j].x, &ps[i][j].y);
    bool found = false;
    int fi, fj, si, sj;
    for (int i0 = 0; !found && i0 < 3; i0++)
      for (int i1 = i0 + 1; !found && i1 < 3; i1++)
        for (int j0 = 0; !found && j0 < 2; j0++)
          for (int j1 = 0; !found && j1 < 2; j1++)
            if (ps[i0][j0] == ps[i1][j1]) {
              found = true;
              fi = i0, fj = j0, si = i1, sj = j1;
            }
    if (!found) {
      puts("NO");
      continue;
    }
    if (fi > 0) swap(ps[0], ps[fi]);
    if (fj > 0) swap(ps[0][0], ps[0][1]);
    if (si > 1) swap(ps[1], ps[si]);
    if (sj > 0) swap(ps[1][0], ps[1][1]);
    Pt<double> v0(ps[0][1] - ps[0][0]), v1(ps[1][1] - ps[1][0]);
    if (v0.dot(v1) < 0.0) {
      puts("NO");
      continue;
    }
    if ((ps[2][0] - ps[0][0]).cross(ps[2][0] - ps[0][1]) != 0.0)
      swap(ps[2][0], ps[2][1]);
    Pt<double> mv00(ps[2][0] - ps[0][0]), mv01(ps[2][0] - ps[0][1]);
    Pt<double> mv10(ps[2][1] - ps[1][0]), mv11(ps[2][1] - ps[1][1]);
    if (mv00.cross(mv01) != 0.0 || mv00.dot(mv01) >= 0.0 ||
        mv10.cross(mv11) != 0.0 || mv10.dot(mv11) >= 0.0) {
      puts("NO");
      continue;
    }
    double d0 = mv00.d2() / mv01.d2(), d1 = mv10.d2() / mv11.d2();
    if (d0 < 1.0 / 16 || d0 > 16.0 || d1 < 1.0 / 16 || d1 > 16.0) {
      puts("NO");
      continue;
    }
    puts("YES");
  }
  return 0;
}
