#include <bits/stdc++.h>
using namespace std;
int t;
struct point {
  long long x, y;
  point(long long a = 0, long long b = 0) {
    x = a;
    y = b;
  }
};
pair<point, point> a[4], now[4];
bool eq(point a, point b) { return a.x == b.x && a.y == b.y; }
bool lss(point a, point b) {
  return ((a.x < b.x) || (a.x == b.x && a.y <= b.y));
}
bool operator<(const point &a, const point &b) {
  return a.x < b.x || a.x == b.x && a.y < b.y;
}
bool on(point p, point lf, point rg) {
  return lss(lf, p) && lss(p, rg) || lss(rg, p) && lss(p, lf);
}
int sq(point a, point b, point c) {
  return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
}
bool at(point p, point lf, point rg) {
  return sq(lf, p, rg) == 0 && on(p, lf, rg);
}
long long dist(const point &a, const point &b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool ok(pair<point, point> *now) {
  if (!eq(now[0].first, now[1].first)) return 0;
  if (!at(now[2].first, now[0].first, now[0].second) ||
      !at(now[2].second, now[1].first, now[1].second))
    return 0;
  if (sq(now[0].first, now[0].second, now[1].second) == 0) return 0;
  if (dist(now[0].first, now[0].second) + dist(now[1].first, now[1].second) <
      dist(now[0].second, now[1].second))
    return 0;
  if (dist(now[2].first, now[0].first) * 16 < dist(now[2].first, now[0].second))
    return 0;
  if (dist(now[2].first, now[0].second) * 16 < dist(now[2].first, now[0].first))
    return 0;
  if (dist(now[2].second, now[1].first) * 16 <
      dist(now[2].second, now[1].second))
    return 0;
  if (dist(now[2].second, now[1].second) * 16 <
      dist(now[2].second, now[1].first))
    return 0;
  return 1;
}
int main() {
  scanf("%d", &t);
  int ii, i, j, k;
  for (ii = 1; ii <= t; ++ii) {
    for (i = 0; i < 3; ++i) {
      scanf("%I64Ld%I64Ld", &a[i].first.x, &a[i].first.y);
      scanf("%I64Ld%I64Ld", &a[i].second.x, &a[i].second.y);
    }
    for (i = 0; i < 6; ++i) {
      for (j = 0; j < 8; ++j) {
        memcpy(now, a, sizeof(a));
        for (k = 0; k < 3; ++k)
          if ((j >> k) & 1) swap(now[k].first, now[k].second);
        if (ok(now)) break;
      }
      if (j < 8) break;
      next_permutation(a, a + 3);
    }
    if (i < 6)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
