#include <bits/stdc++.h>
using namespace std;
using namespace std;
double xx, yy;
struct Point {
  long double x, y;
  Point(long double _x, long double _y) {
    x = _x;
    y = _y;
  }
  Point() {}
  long double mod() { return sqrt(x * x + y * y); }
  long double mod2() { return x * x + y * y; }
  long double arg() { return atan2(y, x); }
  Point ort() { return Point(-y, x); }
  Point rev() { return Point(y, x); }
  Point unit() {
    long double k = mod();
    return Point(x / k, y / k);
  }
  void read() {
    scanf("%lf%lf", &xx, &yy);
    x = xx;
    y = yy;
  }
};
bool operator<(const Point &P1, const Point &P2) {
  return (P1.x != P2.x) ? (P1.x < P2.x) : (P1.y < P2.y);
}
bool operator==(const Point &P1, const Point &P2) {
  return fabs(P1.x - P2.x) < 1e-8 && fabs(P1.y - P2.y) < 1e-8;
}
bool operator>(const Point &P1, const Point &P2) {
  return !(P1 == P2) && !(P1 < P2);
}
bool operator!=(const Point &P1, const Point &P2) { return !(P1 == P2); }
Point operator-(const Point &p1, const Point &p2) {
  return Point(p1.x - p2.x, p1.y - p2.y);
}
Point operator+(const Point &p1, const Point &p2) {
  return Point(p1.x + p2.x, p1.y + p2.y);
}
Point operator*(const Point &p, double k) { return Point(p.x * k, p.y * k); }
Point operator/(const Point &p, double k) { return Point(p.x / k, p.y / k); }
long double dot(const Point &v1, const Point &v2) {
  return v1.x * v2.x + v1.y * v2.y;
}
long double cross(const Point &v1, const Point &v2) {
  return v1.x * v2.y - v1.y * v2.x;
}
long double dis(const Point &P1, const Point &P2) { return (P1 - P2).mod(); }
long double area(const Point &A, const Point &B, const Point &C) {
  return cross(B - A, C - A);
}
struct line {
  Point p1, p2;
  line(Point _p1, Point _p2) {
    p1 = _p1;
    p2 = _p2;
  }
  line() {}
  Point dir() { return p2 - p1; }
  long double mod() { return (p2 - p1).mod(); }
};
bool onSegment(Point P, line L) {
  return fabs(cross(L.dir(), P - L.p1)) < 1e-8 &&
         dot(P - L.p1, P - L.p2) < 1e-8;
}
bool intersects(line L1, line L2) {
  if (onSegment(L1.p1, L2)) return true;
  if (onSegment(L1.p2, L2)) return true;
  if (onSegment(L2.p1, L1)) return true;
  if (onSegment(L2.p2, L1)) return true;
  long double A11 = cross(L1.dir(), L2.p1 - L1.p1);
  long double A12 = cross(L1.dir(), L2.p2 - L1.p1);
  long double A21 = cross(L2.dir(), L1.p1 - L2.p1);
  long double A22 = cross(L2.dir(), L1.p2 - L2.p1);
  if (A11 > 1e-8) swap(A11, A12);
  if (A21 > 1e-8) swap(A21, A22);
  return (A11 < 0 && A12 > 1e-8) && (A21 < 0 && A22 > 1e-8);
}
Point lineIntersection(line S1, line S2) {
  return S1.p1 + S1.dir() * (cross(S2.p1 - S1.p1, S2.dir()) /
                             cross(S1.dir(), S2.dir()));
}
line L[3];
map<Point, int> mapa;
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    Point l, r;
    bool ok = true;
    set<Point> S;
    mapa.clear();
    for (int i = 0; i < 3; i++) {
      l.read();
      r.read();
      if (l == r) ok = false;
      L[i] = line(l, r);
      mapa[l]++;
      mapa[r]++;
      S.insert(l);
      S.insert(r);
    }
    int ct = 0;
    vector<Point> v(S.begin(), S.end());
    for (int i = 0; i < v.size(); i++)
      if (mapa[v[i]] == 2) ct++, l = v[i];
    if (ct != 1)
      puts("NO");
    else {
      for (int i = 0; i < 3; i++)
        if (L[i].p1 != l) swap(L[i].p1, L[i].p2);
      if (L[1].p1 == l) swap(L[0], L[1]);
      if (L[2].p1 == l) swap(L[0], L[2]);
      if (L[2].p1 == l) swap(L[1], L[2]);
      double teta = dot(L[0].p2 - L[0].p1, L[1].p2 - L[1].p1);
      teta /= (L[0].mod() * L[1].mod());
      teta = acos(teta);
      teta = min(teta, 2 * (atan2(0, -1)) - teta);
      if (teta > (atan2(0, -1)) / 2.0 + 1e-8 || abs(teta) < 1e-8) ok = false;
      if (!intersects(L[0], L[2]) || !intersects(L[1], L[2])) ok = false;
      if (onSegment(L[2].p1, L[1]) && onSegment(L[2].p2, L[0]))
        swap(L[2].p1, L[2].p2);
      if (!onSegment(L[2].p1, L[0]) || !onSegment(L[2].p2, L[1])) ok = false;
      if (!ok)
        puts("NO");
      else {
        Point p0 = L[2].p1;
        Point p1 = L[2].p2;
        double l1, l2;
        l1 = (p0 - L[0].p1).mod();
        l2 = (p0 - L[0].p2).mod();
        if (l1 > l2) swap(l1, l2);
        if (4 * l1 + 1e-8 < l2) ok = false;
        l1 = (p1 - L[1].p1).mod();
        l2 = (p1 - L[1].p2).mod();
        if (l1 > l2) swap(l1, l2);
        if (4 * l1 + 1e-8 < l2) ok = false;
        if (ok)
          puts("YES");
        else
          puts("NO");
      }
    }
  }
}
