#include <bits/stdc++.h>
using namespace std;
struct P {
  int64_t x = 0, y = 0;
  P() {}
  P(int64_t x, int64_t y) : x(x), y(y) {}
  bool operator==(const P& b) const { return x == b.x && y == b.y; }
  P operator-(const P& b) const { return P(x - b.x, y - b.y); }
  int64_t operator*(const P& b) const { return x * b.x + y * b.y; }
  int64_t operator/(const P& b) const { return x * b.y - y * b.x; }
};
template <typename T>
int64_t sqr(const T& a) {
  return a * a;
}
int64_t dis2(const P& a) { return sqr(a); }
struct S {
  P p, q;
};
int64_t dis2(const S& s) { return dis2(s.p - s.q); }
bool inside(P a, P b, P c) {
  return (a / b == 0) && (a / c == 0) && ((a * c > 0 && b * c > 0));
}
bool check(S a, S b, S c) {
  if (a.p == b.p)
    ;
  else if (a.p == b.q) {
    swap(b.p, b.q);
  } else if (a.q == b.p) {
    swap(a.p, a.q);
  } else if (a.q == b.q) {
    swap(a.p, a.q);
    swap(b.p, b.q);
  } else
    return false;
  if (dis2(a) <= 0 || dis2(b) <= 0 || dis2(c) <= 0) return false;
  if ((b.q - b.p) * (a.q - a.p) < 0) return false;
  if ((a.q - a.p) / (b.q - b.p) == 0) return false;
  int64_t s1 = dis2(c.p - a.p);
  int64_t s2 = dis2(c.p - a.q);
  int64_t t1 = dis2(c.q - b.p);
  int64_t t2 = dis2(c.q - b.q);
  int64_t ss = dis2(a);
  int64_t tt = dis2(b);
  if (inside(c.p - a.p, a.q - c.p, a.q - a.p) &&
      inside(c.q - b.p, b.q - c.q, b.q - b.p)) {
    if (s1 * 25 >= ss && s2 * 25 >= ss && t1 * 25 >= tt && t2 * 25 >= tt)
      return true;
  } else {
    s1 = dis2(c.q - a.p);
    s2 = dis2(c.q - a.q);
    t1 = dis2(c.p - b.p);
    t2 = dis2(c.p - b.q);
    if (inside(c.q - a.p, a.q - c.q, a.q - a.p) &&
        inside(c.p - b.p, b.q - c.p, b.q - b.p)) {
      if (s1 * 25 >= ss && s2 * 25 >= ss && t1 * 25 >= tt && t2 * 25 >= tt)
        return true;
    }
  }
  return false;
}
int main() {
  int n;
  ios_base::sync_with_stdio(false);
  cin >> n;
  while (n--) {
    S s[3];
    for (int i = 0; i < 3; ++i)
      cin >> s[i].p.x >> s[i].p.y >> s[i].q.x >> s[i].q.y;
    if (check(s[0], s[1], s[2]) || check(s[0], s[2], s[1]) ||
        check(s[1], s[0], s[2]) || check(s[1], s[2], s[0]) ||
        check(s[2], s[0], s[1]) || check(s[2], s[1], s[0]))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
