#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
map<pair<int, int>, bool> ma;
struct point {
  long long x, y;
  point(long long x = 0, long long y = 0) {
    this->x = x;
    this->y = y;
  }
  point operator+(const point& a) const { return point(x + a.x, y + a.y); }
  point operator-(const point& a) const { return point(x - a.x, y - a.y); }
  bool operator==(point& p) { return p.x == x && p.y == y; }
};
struct line {
  double a, b, c;
  point A, B;
  line(double a = 0, double b = 0, double c = 0) : a(a), b(b), c(c) {}
  line(point A, point B) : A(A), B(B) {
    a = B.y - A.y;
    b = A.x - B.x;
    c = -(a * A.x + b * A.y);
  }
};
struct vecto {
  long long x, y;
  vecto(long long x = 0, long long y = 0) {
    this->x = x;
    this->y = y;
  }
  bool operator==(vecto& v) { return v.x == x && v.y == y; }
  bool operator<(const vecto& v) const {
    if (v.x == x) return y < v.y;
    return x < v.x;
  }
};
vecto toVec(point a, point b) { return vecto(b.x - a.x, b.y - a.y); }
line a[3];
long long crossProduct(point first, point second, point third) {
  return (second.x - first.x) * (third.y - first.y) -
         (second.y - first.y) * (third.x - first.x);
}
bool between(long long a, long long b, long long c) {
  if (a > b) swap(a, b);
  return (c >= a && c <= b);
}
bool on(point b, line a) {
  if (crossProduct(a.A, a.B, b)) return false;
  return (between(a.A.x, a.B.x, b.x) && between(a.A.y, a.B.y, b.y));
}
long long dist(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
long long dotProduct(vecto a, vecto b) { return a.x * b.x + a.y * b.y; }
bool checkProportion(line a, point b) {
  long long distA = dist(a.A, b);
  long long distB = dist(a.B, b);
  if (distA > distB) swap(distA, distB);
  return 16 * distA >= distB;
}
bool checkAngle(line a, line b) {
  vecto u = toVec(a.A, a.B);
  vecto v = toVec(b.A, b.B);
  if (u.x * v.y == v.x * u.y) return false;
  if (dotProduct(u, v) < 0) return false;
  return true;
}
bool check(line a, line b, line c) {
  if (!(a.A == b.A) && !(a.A == b.B) && !(a.B == b.A) && !(a.B == b.B))
    return false;
  if (a.A == b.B)
    swap(b.A, b.B);
  else if (a.B == b.A)
    swap(a.A, a.B);
  else if (a.B == b.B) {
    swap(a.A, a.B);
    swap(b.A, b.B);
  }
  if (!(on(c.A, a) && on(c.B, b)) && !(on(c.A, b) && on(c.B, a))) return false;
  if (on(c.A, b) && on(c.B, a)) swap(c.A, c.B);
  if (!checkAngle(a, b)) return false;
  return (checkProportion(a, c.A) && checkProportion(b, c.B));
}
point A, B;
int main() {
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    for (int i = (1); i <= (3); i++) {
      cin >> A.x >> A.y >> B.x >> B.y;
      a[i] = line(A, B);
    }
    if (check(a[1], a[2], a[3]) || check(a[3], a[2], a[1]) ||
        check(a[3], a[1], a[2]))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
