#include <bits/stdc++.h>
using namespace std;
const int moves[][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
class Point {
 public:
  Point() {}
  Point(int x, int y) {
    this->x = x;
    this->y = y;
  }
  double dist(Point p) {
    double x = p.x - this->x;
    double y = p.y - this->y;
    return sqrt(x * x + y * y);
  }
  bool operator==(Point a) { return a.x == this->x && a.y == this->y; }
  void read() { scanf("%d%d", &x, &y); }
  int x, y;
};
class Segment {
 public:
  Segment() {}
  Segment(Point a, Point b) {
    p[0] = a;
    p[1] = b;
  }
  Segment(int x1, int y1, int x2, int y2) {
    Segment(Point(x1, y1), Point(x2, y2));
  }
  bool contains(Point t) {
    int a = p[0].y - p[1].y;
    int b = p[1].x - p[0].x;
    int c = p[0].x * p[1].y - p[1].x * p[0].y;
    if (a * t.x + b * t.y + c != 0) return false;
    int m1 = min(p[0].x, p[1].x);
    int m2 = max(p[0].x, p[1].x);
    return min(p[0].x, p[1].x) <= t.x && t.x <= max(p[0].x, p[1].x);
  }
  double getLength() { return p[0].dist(p[1]); }
  void read() {
    p[0].read();
    p[1].read();
  }
  Point p[2];
};
double SP(Point a, Point b) {
  double x = double(a.x) * double(b.x);
  double y = double(a.y) * double(b.y);
  return x + y;
}
bool f1(Segment a, Segment b, Segment c) {
  bool ce = false;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (a.p[i] == b.p[j]) ce = true;
    }
  }
  if (!ce) return false;
  bool p1 = a.contains(c.p[0]) && b.contains(c.p[1]);
  bool p2 = a.contains(c.p[1]) && b.contains(c.p[0]);
  return p1 || p2;
}
bool f2(Segment a, Segment b, Segment c) {
  Point A, B, C;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (a.p[i] == b.p[j]) {
        C = a.p[i];
        A = a.p[(i + 1) % 2];
        B = b.p[(j + 1) % 2];
      }
    }
  }
  A.x -= C.x;
  A.y -= C.y;
  B.x -= C.x;
  B.y -= C.y;
  double da = A.dist(Point(0, 0));
  double db = B.dist(Point(0, 0));
  double sp = SP(A, B);
  double alpha = acos(sp / (da * db));
  if (alpha < 0.0) alpha += 2.0 * 3.141592653589793238;
  if (alpha > 3.141592653589793238) alpha -= 3.141592653589793238;
  if (alpha > 3.141592653589793238 * 0.5) return false;
  return true;
}
bool f3(Segment a, Segment b, Segment c) {
  for (int i = 0; i < 2; i++) {
    if (a.contains(c.p[i])) {
      double d1 = a.p[0].dist(c.p[i]);
      double d2 = a.p[1].dist(c.p[i]);
      if (d1 < 0.0000000000001) return false;
      if (d2 < 0.0000000000001) return false;
      double ratio = d1 / d2;
      if (d1 > d2) ratio = d2 / d1;
      if (ratio < 0.25) return false;
    }
    if (b.contains(c.p[i])) {
      double d1 = b.p[0].dist(c.p[i]);
      double d2 = b.p[1].dist(c.p[i]);
      if (d1 < 0.0000000000001) return false;
      if (d2 < 0.0000000000001) return false;
      double ratio = d1 / d2;
      if (d1 > d2) ratio = d2 / d1;
      if (ratio < 0.25) return false;
    }
  }
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    Segment a[3];
    for (int i = 0; i < 3; i++) a[i].read();
    bool b = false;
    for (int i = 0; i < 3; i++) {
      for (int j = i + 1; j < 3; j++) {
        int k;
        for (k = 0; k < 3 && (k == i || k == j); k++)
          ;
        if (f1(a[i], a[j], a[k]) && f2(a[i], a[j], a[k]) &&
            f3(a[i], a[j], a[k]))
          b = true;
      }
    }
    if (b)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
