#include <bits/stdc++.h>
const int MAX = 3000;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
using namespace std;
bool eq(long double a, long double b) { return fabsl(a - b) <= EPS; }
struct point {
  long double x, y;
  int id;
  point(long double x = 0, long double y = 0) : x(x), y(y) {}
  point operator+(const point &o) const { return {x + o.x, y + o.y}; }
  point operator-(const point &o) const { return {x - o.x, y - o.y}; }
  point operator*(long double t) const { return {x * t, y * t}; }
  point operator/(long double t) const { return {x / t, y / t}; }
  long double operator*(const point &o) const { return x * o.x + y * o.y; }
  long double operator^(const point &o) const { return x * o.y - y * o.x; }
  bool operator<(const point &o) const {
    if (!eq(x, o.x)) return x < o.x;
    return y < o.y;
  }
  bool operator==(const point &o) const { return eq(x, o.x) and eq(y, o.y); }
};
long double norm(point a) { return sqrt(a * a); }
long double proj(point a, point b) { return a * b / norm(b); }
long double max(long double a, long double b) { return (a > b ? a : b); }
long double min(long double a, long double b) { return (a < b ? a : b); }
long double angle(point a, point b) {
  long double ang = a * b / norm(a) / norm(b);
  return acos(max(min(ang, 1), -1));
}
int ccw(point a, point b, point e) {
  long double tmp = (b - a) ^ (e - a);
  return (tmp > EPS) - (tmp < -EPS);
}
struct line {
  point p1, p2;
  line(point p1 = 0, point p2 = 0) : p1(p1), p2(p2) {}
  long double a = p1.y - p2.y;
  long double b = p2.x - p1.x;
  long double c = -(a * p1.x + b * p1.y);
  bool inside(point p) {
    return eq(norm(p1 - p) + norm(p2 - p) - norm(p2 - p1), 0);
  }
};
point intersect(line l1, line l2) {
  long long det = l1.a * l2.b - l1.b * l2.a;
  if (det == 0) return point(INF, INF);
  long double x = (l1.b * l2.c - l1.c * l2.b) / det;
  long double y = (l1.c * l2.a - l1.a * l2.c) / det;
  return point(x, y);
}
bool check(point a[2], point b[2], point m[2]) {
  if (a[0] == b[1])
    swap(b[0], b[1]);
  else if (a[1] == b[0])
    swap(a[0], a[1]);
  else if (a[1] == b[1]) {
    swap(a[0], a[1]);
    swap(b[0], b[1]);
  } else if (!(a[0] == b[0]))
    return false;
  assert(a[0] == b[0]);
  long double ang = angle(a[1] - a[0], b[1] - b[0]);
  if (ang > PI / 2 + EPS or ang < EPS) return false;
  line A = line(a[0], a[1]);
  line B = line(b[0], b[1]);
  line M = line(m[0], m[1]);
  if (A.inside(m[0]) and B.inside(m[1])) {
    if (norm(a[1] - m[0]) > 4 * norm((m[0] - a[0])) or
        norm(a[0] - m[0]) > 4 * norm((m[0] - a[1])))
      return false;
    if (norm(b[1] - m[1]) > 4 * norm((m[1] - b[0])) or
        norm(b[0] - m[1]) > 4 * norm((m[1] - b[1])))
      return false;
    else
      return true;
  } else if (A.inside(m[1]) and B.inside(m[0])) {
    if (norm(a[1] - m[1]) > 4 * norm((m[1] - a[0])) or
        norm(a[0] - m[1]) > 4 * norm((m[1] - a[1])))
      return false;
    if (norm(b[1] - m[0]) > 4 * norm((m[0] - b[0])) or
        norm(b[0] - m[0]) > 4 * norm((m[0] - b[1])))
      return false;
    else
      return true;
  } else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, x, y;
  cin >> t;
  point vet[3][2];
  while (t--) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 2; j++) {
        cin >> x >> y;
        vet[i][j] = point(x, y);
      }
    if (check(vet[0], vet[1], vet[2]) or check(vet[0], vet[2], vet[1]) or
        check(vet[1], vet[2], vet[0]))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
