#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  void in() { scanf("%I64d%I64d", &x, &y); }
  bool equal(point p) { return p.x == x && p.y == y; }
};
point p[3][2];
long long dot(point a, point b, point c) {
  return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}
long long det(point a, point b, point c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
bool on_seg(point a, point b, point c) {
  return dot(a, b, c) < 0 && det(a, b, c) == 0;
}
double dist(point a, point b) {
  return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) +
              1.0 * (a.y - b.y) * (a.y - b.y));
}
double eps = 1e-8;
int dcmp(double x) { return x < -eps ? -1 : x > eps; }
bool solve() {
  int i, j;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) {
      if (p[0][i].equal(p[1][j])) {
        goto end;
      }
    }
end:
  if (i == 2 && j == 2) return false;
  if (i != 0) swap(p[0][0], p[0][1]);
  if (j != 0) swap(p[1][0], p[1][1]);
  if (dot(p[0][0], p[0][1], p[1][1]) < 0 ||
      det(p[0][0], p[0][1], p[1][1]) == 0) {
    return false;
  }
  int cnt = 0;
  if (on_seg(p[2][0], p[0][0], p[0][1])) cnt += 10, i = 0;
  if (on_seg(p[2][1], p[0][0], p[0][1])) cnt += 10, i = 1;
  if (on_seg(p[2][0], p[1][0], p[1][1])) cnt += 1, j = 0;
  if (on_seg(p[2][1], p[1][0], p[1][1])) cnt += 1, j = 1;
  if (cnt != 11) return false;
  if (dcmp(dist(p[2][i], p[0][1])) == 0) return false;
  double d = dist(p[2][i], p[0][0]) / dist(p[2][i], p[0][1]);
  if (dcmp(d - 4) > 0 || dcmp(d - 0.25) < 0) return false;
  if (dcmp(dist(p[2][j], p[1][1])) == 0) return false;
  d = dist(p[2][j], p[1][0]) / dist(p[2][j], p[1][1]);
  if (dcmp(d - 4) > 0 || dcmp(d - 0.25) < 0) return false;
  return true;
}
int main() {
  int runs;
  for (scanf("%d", &runs); runs > 0; runs--) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 2; j++) p[i][j].in();
    bool ok = false;
    for (int i = 0; i < 3; i++) {
      point t[2];
      t[0] = p[0][0], t[1] = p[0][1];
      for (int j = 0; j < 2; j++) p[j][0] = p[j + 1][0], p[j][1] = p[j + 1][1];
      p[2][0] = t[0], p[2][1] = t[1];
      if (solve()) ok = true;
    }
    if (ok)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
