#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) {}
  friend bool operator==(Point a, Point b) { return a.x == b.x && a.y == b.y; }
  friend Point operator-(Point a, Point b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend Point operator+(Point a, Point b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator*(Point a, long long t) {
    return Point(a.x * t, a.y * t);
  }
  friend Point operator/(Point a, long long t) {
    return Point(a.x / t, a.y / t);
  }
  void rd() {
    scanf("%I64d%I64d", &x, &y);
    x *= 5;
    y *= 5;
  }
  void od() { cout << x << " " << y << endl; }
  void Od() { cout << x / 5 << " " << y / 5 << " "; }
};
long long det(Point a, Point b) { return a.x * b.y - a.y * b.x; }
long long det(Point a, Point b, Point o) { return det(a - o, b - o); }
long long dis2(Point a) { return a.x * a.x + a.y * a.y; }
long long dis2(Point a, Point b) { return dis2(a - b); }
long long dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
long long dot(Point a, Point b, Point o) { return dot(a - o, b - o); }
long long dcmp(long long x) {
  if (x == 0) return 0;
  return x > 0 ? 1 : -1;
}
bool seg(Point a, Point b, Point c, Point d) {
  long long d1 = dcmp(det(a, b, c));
  long long d2 = dcmp(det(a, b, d));
  long long d3 = dcmp(det(c, d, a));
  long long d4 = dcmp(det(c, d, b));
  if (d1 * d2 < 0 && d3 * d4 < 0)
    return true;
  else if (d1 == 0 && dot(a, b, c) <= 0)
    return true;
  else if (d2 == 0 && dot(a, b, d) <= 0)
    return true;
  else if (d3 == 0 && dot(c, d, a) <= 0)
    return true;
  else if (d4 == 0 && dot(c, d, b) <= 0)
    return true;
  return false;
}
bool ok(Point a, Point b, Point c) {
  Point lx = (a * 4 + b) / 5;
  Point rx = (a + b * 4) / 5;
  if (det(lx, rx, c) == 0 && dot(lx, rx, c) <= 0) return true;
  return false;
}
bool cc(Point a[2], Point b[2], Point c[2]) {
  if (a[0] == b[1] || a[1] == b[1]) swap(b[0], b[1]);
  if (a[1] == b[0]) swap(a[0], a[1]);
  if (!(a[0] == b[0])) return false;
  if (det(a[1], b[1], a[0]) == 0) return false;
  if (dis2(a[0], a[1]) + dis2(a[0], b[1]) < dis2(a[1], b[1])) return false;
  return ok(a[0], a[1], c[0]) && ok(b[0], b[1], c[1]);
}
int main() {
  int ncase;
  scanf("%d", &ncase);
  Point a[2], b[2], c[2];
  while (ncase--) {
    a[0].rd();
    a[1].rd();
    b[0].rd();
    b[1].rd();
    c[0].rd();
    c[1].rd();
    a[1] = a[1] - a[0];
    b[0] = b[0] - a[0];
    b[1] = b[1] - a[0];
    c[0] = c[0] - a[0];
    c[1] = c[1] - a[0];
    a[0] = a[0] - a[0];
    if (cc(a, b, c) || cc(a, c, b) || cc(b, c, a))
      puts("YES");
    else if (cc(b, a, c) || cc(c, a, b) || cc(c, b, a))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
