#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  double dx, dy;
  bool operator==(Point b) { return x == b.x && y == b.y; }
  Point() {}
  Point(long long cx, long long cy) {
    x = cx;
    y = cy;
  }
};
bool Left(Point &a, Point &b, Point &c) {
  return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y) > 0;
}
bool LeftOn(Point &a, Point &b, Point &c) {
  return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y) >= 0;
}
bool Collinear(Point &a, Point &b, Point &c) {
  return ((b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y)) == 0;
}
bool Xor(bool x, bool y) { return !x ^ !y; }
bool IntersectProp(Point &a, Point &b, Point &c, Point &d) {
  if (Collinear(a, b, c) || Collinear(a, b, d) || Collinear(c, d, a) ||
      Collinear(c, d, b))
    return false;
  return Xor(Left(a, b, c), Left(a, b, d)) && Xor(Left(c, d, a), Left(c, d, b));
}
bool Between(Point &a, Point &b, Point &c) {
  if (!Collinear(a, b, c)) return false;
  if (a.x != b.x)
    return ((a.x <= c.x) && (c.x <= b.x)) || ((a.x >= c.x) && (c.x >= b.x));
  else
    return ((a.y <= c.y) && (c.y <= b.y)) || ((a.y >= c.y) && (c.y >= b.y));
}
bool Intersect(Point &a, Point &b, Point &c, Point &d) {
  if (IntersectProp(a, b, c, d))
    return true;
  else if (Between(a, b, c) || Between(a, b, d) || Between(c, d, a) ||
           Between(c, d, b))
    return true;
  else
    return false;
}
vector<pair<Point, Point> > v;
bool ok;
bool an(Point a, Point b, Point c) {
  long long dx1 = b.x - a.x;
  long long dy1 = b.y - a.y;
  long long dx2 = c.x - a.x;
  long long dy2 = c.y - a.y;
  long long d = dx1 * dx2 + dy1 * dy2;
  if (dx1 * dy2 - dx2 * dy1 == 0) return false;
  return d >= 0;
}
double len(Point a, Point b) {
  double dx = (double)a.dx - (double)b.dx;
  double dy = (double)a.dy - (double)b.dy;
  return sqrt(dx * dy + dy * dy);
}
void intersect(Point p1, Point p2, Point p3, Point p4, Point &ret) {
  double vx = p2.x - p1.x;
  double vy = p2.y - p1.y;
  double vbx = p4.x - p3.x;
  double vby = p4.y - p3.y;
  double t = (vby * ((double)p3.x - (double)p1.x) -
              vbx * ((double)p3.y - (double)p1.y)) /
             (vby * vx - vbx * vy);
  ret.dx = (double)p1.x + vx * t;
  ret.dy = (double)p1.y + vy * t;
}
long long sq(Point a, Point p) {
  long long dx = p.x - a.x;
  long long dy = p.y - a.y;
  return dx * dx + dy * dy;
}
bool c1(int a, int b) {
  Point med = v[b].first;
  if (Between(v[a].first, v[a].second, v[b].second)) med = v[b].second;
  long long va = sq(v[a].first, med);
  long long vb = sq(v[a].second, med);
  if (va > vb) swap(va, vb);
  return (va * 16LL >= vb);
}
void solve(int a, int b, int c) {
  if (!an(v[a].first, v[a].second, v[b].second)) return;
  if (!Intersect(v[a].first, v[a].second, v[c].first, v[c].second) ||
      IntersectProp(v[a].first, v[a].second, v[c].first, v[c].second))
    return;
  if (!Intersect(v[b].first, v[b].second, v[c].first, v[c].second) ||
      IntersectProp(v[b].first, v[b].second, v[c].first, v[c].second))
    return;
  if (!c1(a, c)) return;
  if (!c1(b, c)) return;
  ok = true;
}
void check(int a, int b, int c) {
  if (v[a].first == v[b].first || v[a].first == v[b].second) {
    if (v[a].first == v[b].second) {
      swap(v[b].first, v[b].second);
    }
    solve(a, b, c);
    return;
  }
  if (v[a].second == v[b].first || v[a].second == v[b].second) {
    swap(v[a].first, v[a].second);
    if (v[a].first == v[b].second) {
      swap(v[b].first, v[b].second);
    }
    solve(a, b, c);
  }
}
int main() {
  int tst;
  cin >> tst;
  while (tst--) {
    v.clear();
    for (int i = 0; i < 3; i++) {
      Point a, b;
      cin >> a.x >> a.y;
      cin >> b.x >> b.y;
      v.push_back(make_pair(a, b));
    }
    ok = false;
    for (int i = 0; i < 3; i++) {
      for (int j = i + 1; j < 3; j++) {
        if (!IntersectProp(v[i].first, v[i].second, v[j].first, v[j].second) &&
            Intersect(v[i].first, v[i].second, v[j].first, v[j].second)) {
          for (int k = 0; k < 3; k++) {
            if (k == i || k == j) continue;
            check(i, j, k);
          }
        }
      }
    }
    if (!ok)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
