#include <bits/stdc++.h>
struct CPoint {
  double x;
  double y;
} point[3][2];
inline double max(double a, double b) { return a > b ? a : b; }
inline double min(double a, double b) { return a < b ? a : b; }
int dcmp(double x) {
  if (fabs(x) < 1e-10) return 0;
  if (x > 0) return 1;
  return -1;
}
double cross(CPoint p0, CPoint p1, CPoint p2) {
  return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
}
double dot(CPoint p0, CPoint p1, CPoint p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}
double sqr(double x) { return x * x; }
double dis(CPoint a, CPoint b) { return sqr(a.x - b.x) + sqr(a.y - b.y); }
double angle(CPoint p0, CPoint p1, CPoint p2) {
  if (dcmp(cross(p0, p1, p2)) == 0) return -1;
  return dcmp(dot(p0, p1, p2));
}
int intertect(CPoint p0, CPoint p1, CPoint p2, CPoint p3, CPoint &c) {
  if (dcmp(max(p0.x, p1.x) - min(p2.x, p3.x)) < 0 ||
      dcmp(max(p2.x, p3.x) - min(p0.x, p1.x)) < 0 ||
      dcmp(max(p0.y, p1.y) - min(p2.y, p3.y)) < 0 ||
      dcmp(max(p2.y, p3.y) - min(p1.y, p0.y)) < 0)
    return 0;
  int d1 = dcmp(cross(p0, p1, p2));
  int d2 = dcmp(cross(p0, p1, p3));
  if ((d1 == 0 && d2 == 0) || (d1 != 0 && d2 != 0))
    return 0;
  else {
    if (d1 == 0) {
      if (p2.x >= min(p1.x, p0.x) && p2.x <= max(p1.x, p0.x) &&
          p2.y >= min(p1.y, p0.y) && p2.y <= max(p1.y, p0.y))
        c = p2;
      else
        return 0;
    } else {
      if (p3.x >= min(p1.x, p0.x) && p3.x <= max(p1.x, p0.x) &&
          p3.y >= min(p1.y, p0.y) && p3.y <= max(p1.y, p0.y))
        c = p3;
      else
        return 0;
    }
    return 1;
  }
}
void swap(double &x, double &y) {
  double z = x;
  x = y;
  y = z;
}
int check(CPoint a, CPoint b) {
  return (dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0);
}
int judge(CPoint p0, CPoint p1, CPoint p2, CPoint p3, CPoint p4, CPoint p5) {
  int flag = 0;
  CPoint p[7];
  if (check(p0, p2)) {
    p[1] = p0;
    p[2] = p1;
    p[3] = p3;
    flag = 1;
  } else {
    if (check(p0, p3)) {
      p[1] = p0;
      p[2] = p1;
      p[3] = p2;
      flag = 1;
    } else {
      if (check(p1, p2)) {
        p[1] = p1;
        p[2] = p0;
        p[3] = p3;
        flag = 1;
      } else if (check(p1, p3)) {
        p[1] = p1;
        p[2] = p0;
        p[3] = p2;
        flag = 1;
      }
    }
  }
  if (flag == 0) return 0;
  double an = angle(p[1], p[2], p[3]);
  if (an < 0) return 0;
  if (intertect(p[1], p[2], p4, p5, p[4]) &&
      intertect(p[1], p[3], p4, p5, p[5])) {
    if (check(p[4], p[5])) return 0;
    double d1 = dis(p[1], p[4]);
    double d2 = dis(p[2], p[4]);
    double d3 = dis(p[1], p[5]);
    double d4 = dis(p[3], p[5]);
    if (d1 > d2) swap(d1, d2);
    if (d3 > d4) swap(d3, d4);
    if (dcmp(d1 * 16 - d2) < 0 || dcmp(d3 * 16 - d4) < 0) {
      return 0;
    }
    return 1;
  }
  return 0;
}
int main() {
  int cases, i;
  while (scanf("%d", &cases) != EOF) {
    while (cases--) {
      int flag = 0;
      for (i = 0; i < 3; i++) {
        scanf("%lf %lf %lf %lf", &point[i][0].x, &point[i][0].y, &point[i][1].x,
              &point[i][1].y);
      }
      for (i = 0; i < 3; i++) {
        if (judge(point[i][0], point[i][1], point[(i + 1) % 3][0],
                  point[(i + 1) % 3][1], point[(i + 2) % 3][0],
                  point[(i + 2) % 3][1])) {
          flag = 1;
          printf("YES\n");
          break;
        }
      }
      if (flag == 0) printf("NO\n");
    }
  }
  return 0;
}
