#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, M = 2e6;
const long long mod = 1e9 + 7;
inline int read() {
  int ret = 0;
  char ch = getchar();
  bool f = 1;
  for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^ '-');
  for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;
  return f ? ret : -ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
const double EPS = 1e-15;
inline int sign(double a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(double a, double b) { return sign(a - b); }
struct P {
  double x, y;
  P() {}
  P(double _x, double _y) : x(_x), y(_y) {}
  P operator+(P p) { return {x + p.x, y + p.y}; }
  P operator-(P p) { return {x - p.x, y - p.y}; }
  P operator*(double d) { return {x * d, y * d}; }
  P operator/(double d) { return {x / d, y / d}; }
  bool operator<(P p) const {
    int c = cmp(x, p.x);
    if (c) return c == -1;
    return cmp(y, p.y) == -1;
  }
  bool operator==(P o) const { return cmp(x, o.x) == 0 && cmp(y, o.y) == 0; }
  void scan() {
    double k1, k2;
    scanf("%lf%lf", &k1, &k2);
    x = k1, y = k2;
  }
  void print() { printf("(%.0f,%.0f)", x, y); }
  double dot(P p) { return x * p.x + y * p.y; }
  double det(P p) { return x * p.y - y * p.x; }
  double distTo(P p) { return (*this - p).abs(); }
  double alpha() { return atan2(y, x); }
  double abs() { return sqrt(abs2()); }
  double abs2() { return x * x + y * y; }
  P rot90() { return P(-y, x); }
  P unit() { return *this / abs(); }
  double distTTo(P p) { return hypot(x - p.x, y - p.y); }
  int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
};
bool isMiddle(double a, double m, double b) {
  return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
bool isMiddle(P a, P m, P b) {
  return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}
bool onSeg(P p1, P p2, P q) {
  return sign(((p2.x - p1.x) * (q.y - p1.y) - (q.x - p1.x) * (p2.y - p1.y))) ==
             0 &&
         isMiddle(p1, q, p2);
}
bool onSeg_strict(P p1, P p2, P q) {
  return sign(((p2.x - p1.x) * (q.y - p1.y) - (q.x - p1.x) * (p2.y - p1.y))) ==
             0 &&
         sign((q - p1).dot(p1 - p2)) * sign((q - p2).dot(p1 - p2)) < 0;
}
P p[4][2];
int a, b, c;
pair<int, int> judge() {
  for (int i = 1; i <= 3; i++)
    for (int j = i + 1; j <= 3; j++)
      for (int k = 0; k < 2; k++)
        for (int z = 0; z < 2; z++) {
          if (p[i][k] == p[j][z]) {
            return make_pair(i, j);
          }
        }
  return make_pair(0, 0);
}
bool judge2() {
  int res1 = 0, res2 = 0;
  if (onSeg(p[a][0], p[a][1], p[c][0])) {
    res1 = 1;
  }
  if (onSeg(p[b][0], p[b][1], p[c][0])) {
    if (res1 == 1) return false;
    res1 = 2;
  }
  if (onSeg(p[a][0], p[a][1], p[c][1])) {
    res2 = 1;
    if (res1 == 1) return false;
  }
  if (onSeg(p[b][0], p[b][1], p[c][1])) {
    if (res2 == 1) return false;
    res2 = 2;
    if (res1 == 2) return false;
  }
  if (res1 + res2 != 3) return false;
  double dis1, dis2;
  if (res1 == 1) {
    dis1 = p[c][0].distTo(p[a][0]);
    dis2 = p[c][0].distTo(p[a][1]);
    if (cmp(dis1, 0.0) == 0 || cmp(dis2, 0.0) == 0) return false;
    if (cmp(dis1, dis2) > 0) {
      if (cmp(dis2 / dis1, 0.25) < 0) return false;
    } else {
      if (cmp(dis1 / dis2, 0.25) < 0) return false;
    }
    dis1 = p[c][1].distTo(p[b][0]);
    dis2 = p[c][1].distTo(p[b][1]);
    if (cmp(dis1, 0.0) == 0 || cmp(dis2, 0.0) == 0) return false;
    if (cmp(dis1, dis2) > 0) {
      if (cmp(dis2 / dis1, 0.25) < 0) return false;
    } else {
      if (cmp(dis1 / dis2, 0.25) < 0) return false;
    }
  } else {
    dis1 = p[c][0].distTo(p[b][0]);
    dis2 = p[c][0].distTo(p[b][1]);
    if (cmp(dis1, 0.0) == 0 || cmp(dis2, 0.0) == 0) return false;
    if (cmp(dis1, dis2) > 0) {
      if (cmp(dis2 / dis1, 0.25) < 0) return false;
    } else {
      if (cmp(dis1 / dis2, 0.25) < 0) return false;
    }
    dis1 = p[c][1].distTo(p[a][0]);
    dis2 = p[c][1].distTo(p[a][1]);
    if (cmp(dis1, 0.0) == 0 || cmp(dis2, 0.0) == 0) return false;
    if (cmp(dis1, dis2) > 0) {
      if (cmp(dis2 / dis1, 0.25) < 0) return false;
    } else {
      if (cmp(dis1 / dis2, 0.25) < 0) return false;
    }
  }
  return true;
}
bool judge3() {
  if (p[a][0] == p[b][0]) {
    if (sign((p[a][0] - p[a][1]).dot(p[a][0] - p[b][1])) < 0) return false;
  } else if (p[a][0] == p[b][1]) {
    if (sign((p[a][0] - p[a][1]).dot(p[a][0] - p[b][0])) < 0) return false;
  } else if (p[a][1] == p[b][0]) {
    if (sign((p[a][1] - p[a][0]).dot(p[a][1] - p[b][1])) < 0) return false;
  } else if (p[a][1] == p[b][1]) {
    if (sign((p[a][1] - p[a][0]).dot(p[a][1] - p[b][0])) < 0) return false;
  }
  return true;
}
int main() {
  int t;
  pair<int, int> res;
  scanf("%d", &t);
  while (t--) {
    p[1][0].scan();
    p[1][1].scan();
    p[2][0].scan();
    p[2][1].scan();
    p[3][0].scan();
    p[3][1].scan();
    res = judge();
    if (res.first == 0) {
      puts("NO");
      continue;
    }
    a = res.first;
    b = res.second;
    c = 6 - a - b;
    if (!judge3()) {
      puts("NO");
      continue;
    }
    if (judge2())
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
