#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point() {}
  point(long long x, long long y) : x(x), y(y) {}
};
struct line {
  long long a, b, c;
  line() {}
  line(point p0, point p1) {
    a = p0.y - p1.y;
    b = p1.x - p0.x;
    c = p0.x * p1.y - p1.x * p0.y;
  }
};
void input(void);
void solve(void);
int is_A(int a, int b, int c);
int ccw(point p0, point p1, point p2);
long long dist(point p1, point p2);
int between(point p1, point p2, point p);
point S[3][2];
int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    input();
    solve();
  }
  return 0;
}
void input(void) {
  for (int i = 0; i < 3; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    S[i][0] = point(x1, y1);
    S[i][1] = point(x2, y2);
  }
}
void solve(void) {
  int found = 0;
  for (int a = 0; a < 3; a++)
    for (int b = 0; b < 3; b++)
      for (int c = 0; c < 3; c++) {
        if (a == b || a == c || b == c) continue;
        if (is_A(a, b, c)) found = 1;
      }
  printf("%s\n", found ? "YES" : "NO");
}
int is_A(int a, int b, int c) {
  point p;
  int found = 0;
  point p1, p2, p3;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      if (dist(S[a][i], S[b][j]) == 0) {
        if (between(S[a][0], S[a][1], S[b][!j])) continue;
        if (between(S[b][0], S[b][1], S[a][!i])) continue;
        found = 1;
        p1 = S[a][i];
        p2 = S[a][!i];
        p3 = S[b][!j];
      }
    }
  if (!found) return 0;
  point u = point(p2.x - p1.x, p2.y - p1.y);
  point v = point(p3.x - p1.x, p3.y - p1.y);
  long long z = u.x * v.x + u.y * v.y;
  if (z < 0) return 0;
  for (int i = 0; i < 2; i++) {
    if (between(S[a][0], S[a][1], S[c][i]) &&
        between(S[b][0], S[b][1], S[c][!i])) {
      long long aa = min(dist(S[a][0], S[c][i]), dist(S[a][1], S[c][i]));
      long long bb = max(dist(S[a][0], S[c][i]), dist(S[a][1], S[c][i]));
      if (16 * aa < bb) continue;
      aa = min(dist(S[b][0], S[c][!i]), dist(S[b][1], S[c][!i]));
      bb = max(dist(S[b][0], S[c][!i]), dist(S[b][1], S[c][!i]));
      if (16 * aa < bb) continue;
      return 1;
    }
  }
  return 0;
}
int ccw(point p0, point p1, point p2) {
  line l = line(p0, p1);
  long long z = l.a * p2.x + l.b * p2.y + l.c;
  if (z < -1e-7) return -1;
  if (z > +1e-7) return +1;
  return 0;
}
int between(point p1, point p2, point p) {
  if (ccw(p1, p2, p) != 0) return 0;
  if (p.x < min(p1.x, p2.x) || p.x > max(p1.x, p2.x)) return 0;
  if (p.y < min(p1.y, p2.y) || p.y > max(p1.y, p2.y)) return 0;
  return 1;
}
long long dist(point p1, point p2) {
  return ((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y));
}
