#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  int id;
} q[10];
int cnt;
long long xmulti(point a, point b, point c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
long long pmulti(point a, point b, point c) {
  return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}
long long dis(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool operator==(point a, point b) {
  if (a.x == b.x && a.y == b.y) return 1;
  return 0;
}
bool work(point c, point a, point b) {
  if (c.x < min(a.x, b.x) || c.x > max(a.x, b.x)) return 0;
  if (c.y < min(a.y, b.y) || c.y > max(a.y, b.y)) return 0;
  if (xmulti(c, a, b) != 0) return 0;
  long long l0 = dis(c, a);
  long long l1 = dis(c, b);
  long long mi, mx;
  mi = min(l0, l1);
  mx = max(l0, l1);
  if (mi * 16 < mx) return 0;
  return 1;
}
int main() {
  int i, j, cas;
  point t0, t1;
  cin >> cas;
  while (cas--) {
    cnt = 0;
    for (i = 0; i < 3; i++) {
      cin >> q[cnt].x >> q[cnt].y;
      q[cnt++].id = i;
      cin >> q[cnt].x >> q[cnt].y;
      q[cnt++].id = i;
    }
    int a, b, c, d, t = 0;
    for (i = 0; i < 6; i++)
      for (j = i + 1; j < 6; j++) {
        if (q[i] == q[j]) {
          a = i, b = j;
          t++;
        }
      }
    if (t != 1) {
      cout << "NO" << endl;
      continue;
    }
    int ida, idb;
    for (i = 0; i < 6; i++) {
      if (i != a && q[i].id == q[a].id) ida = i;
      if (i != b && q[i].id == q[b].id) idb = i;
    }
    if (xmulti(q[a], q[ida], q[idb]) != 0 &&
        pmulti(q[a], q[ida], q[idb]) >= 0) {
      c, d;
      c = d = -1;
      for (i = 0; i < 6; i++) {
        if (q[i].id != q[a].id && q[i].id != q[b].id) {
          if (c == -1)
            c = i;
          else
            d = i;
        }
      }
      if ((work(q[c], q[a], q[ida]) && work(q[d], q[b], q[idb])) ||
          (work(q[d], q[a], q[ida]) && work(q[c], q[b], q[idb]))) {
        cout << "YES" << endl;
        continue;
      }
    }
    cout << "NO" << endl;
  }
  return 0;
}
