#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using point = complex<ld>;
bool onSegment(point p, point a1, point a2) {
  return (fabs(((conj(((a2) - (a1))) * (((p) - (a1)))).imag())) < 1e-9 &&
          ((conj(((a2) - (a1))) * (((p) - (a1)))).real()) > -1e-9 &&
          ((conj(((a1) - (a2))) * (((p) - (a2)))).real()) > -1e-9);
}
int main() {
  int t, x, y;
  cin >> t;
  while (t--) {
    point f, s, th1, th2, com;
    bool flag = 0;
    vector<point> v(6);
    for (int i = 0; i < 6; i++) {
      scanf("%d%d", &x, &y);
      v[i] = point(x, y);
    }
    for (int i = 0; i < 6; i++) {
      int idx = find(v.begin() + i + 1, v.end(), v[i]) - v.begin();
      if (idx != 6) {
        com = v[i], f = v[i ^ 1], s = v[idx ^ 1];
        if (i > 1)
          th1 = v[0], th2 = v[1];
        else if (idx < 4)
          th1 = v[4], th2 = v[5];
        else
          th1 = v[2], th2 = v[3];
      }
    }
    if (onSegment(th1, f, com) && onSegment(th2, s, com)) {
      ld l1 =
          ((long double)hypot((((com) - (th1))).imag(),
                              (((com) - (th1))).real())) /
          ((long double)hypot((((f) - (th1))).imag(), (((f) - (th1))).real()));
      ld l2 =
          ((long double)hypot((((com) - (th2))).imag(),
                              (((com) - (th2))).real())) /
          ((long double)hypot((((s) - (th2))).imag(), (((s) - (th2))).real()));
      flag = (l1 >= 0.25 - 1e-9 && l1 <= 4 + 1e-9 && l2 >= 0.25 - 1e-9 &&
              l2 <= 4 + 1e-9);
    }
    if (onSegment(th2, f, com) && onSegment(th1, s, com)) {
      ld l1 =
          ((long double)hypot((((com) - (th2))).imag(),
                              (((com) - (th2))).real())) /
          ((long double)hypot((((f) - (th2))).imag(), (((f) - (th2))).real()));
      ld l2 =
          ((long double)hypot((((com) - (th1))).imag(),
                              (((com) - (th1))).real())) /
          ((long double)hypot((((s) - (th1))).imag(), (((s) - (th1))).real()));
      flag |= (l1 >= 0.25 - 1e-9 && l1 <= 4 + 1e-9 && l2 >= 0.25 - 1e-9 &&
               l2 <= 4 + 1e-9);
    }
    ld a = (fabs((atan2((((f) - (com))).imag(), (((f) - (com))).real())) -
                 (atan2((((s) - (com))).imag(), (((s) - (com))).real()))) /
            3.141592653589793238L * 180);
    a = min(a, 360 - a);
    puts((!flag || a < 1e-9 || a > 90 + 1e-9) ? "NO" : "YES");
  }
  return 0;
}
