#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000;
const int INF = 1e9;
const long long LINF = 1e18;
const int WOW = 40000;
const int NIL = 0;
const int dy[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const double PI = 2 * acos(0);
long long cross(long long x1, long long y1, long long x2, long long y2) {
  return x1 * y2 - y1 * x2;
}
long long dot(long long x1, long long y1, long long x2, long long y2) {
  return x1 * x2 + y1 * y2;
}
long long len(long long x, long long y) { return x * x + y * y; }
struct Segment {
  long long x1, y1, x2, y2;
  void read() { scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2); }
  void rev() { swap(x1, x2), swap(y1, y2); }
  bool adjust(Segment& t) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        if (x1 == t.x1 && y1 == t.y1) return 1;
        t.rev();
      }
      rev();
    }
    return 0;
  }
  bool angle(const Segment& t) {
    return cross(x2 - x1, y2 - y1, t.x2 - x1, t.y2 - y1) != 0 &&
           dot(x2 - x1, y2 - y1, t.x2 - x1, t.y2 - y1) >= 0;
  }
  bool contain(long long x, long long y) {
    return cross(x1 - x, y1 - y, x2 - x, y2 - y) == 0 &&
           dot(x1 - x, y1 - y, x2 - x, y2 - y) < 0;
  }
  bool divide(long long x, long long y) {
    long long u = len(x1 - x, y1 - y), v = len(x2 - x, y2 - y);
    if (u > v) swap(u, v);
    return 16 * u >= v;
  }
} s[3];
bool solve(long long a, long long b, long long c) {
  if (!s[a].adjust(s[b])) return 0;
  if (!s[a].angle(s[b])) return 0;
  if (s[a].contain(s[c].x1, s[c].y1) && s[b].contain(s[c].x2, s[c].y2)) {
    if (!s[a].divide(s[c].x1, s[c].y1) || !s[b].divide(s[c].x2, s[c].y2))
      return 0;
  } else if (s[b].contain(s[c].x1, s[c].y1) && s[a].contain(s[c].x2, s[c].y2)) {
    if (!s[b].divide(s[c].x1, s[c].y1) || !s[a].divide(s[c].x2, s[c].y2))
      return 0;
  } else
    return 0;
  return 1;
}
int T;
int main() {
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < 3; ++i) s[i].read();
    puts(solve(0, 1, 2) || solve(0, 2, 1) || solve(1, 0, 2) || solve(1, 2, 0) ||
                 solve(2, 0, 1) || solve(2, 1, 0)
             ? "YES"
             : "NO");
  }
}
