#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point operator-(point u) {
    point ret;
    ret.x = x - u.x;
    ret.y = y - u.y;
    return ret;
  }
  bool operator==(point u) { return (x == u.x && y == u.y); }
  long long operator*(point u) { return x * u.x + y * u.y; }
};
struct seg {
  point p1, p2;
} A, B, C;
bool check_it(point u, point v) {
  if (u.x * v.y != u.y * v.x) return false;
  if (u * v > 0) return false;
  long long x1 = u.x;
  long long x2 = v.x;
  if (x1 == 0) x1 = u.y, x2 = v.y;
  if (x1 * x2 > 0) return false;
  x1 = abs(x1);
  x2 = abs(x2);
  if (x1 > 4 * x2) return false;
  if (x2 > 4 * x1) return false;
  return true;
}
bool check() {
  if (check_it(C.p1 - A.p1, C.p1 - A.p2) && check_it(C.p2 - B.p1, C.p2 - B.p2))
    return true;
  if (check_it(C.p1 - B.p1, C.p1 - B.p2) && check_it(C.p2 - A.p1, C.p2 - A.p2))
    return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (cin >> A.p1.x >> A.p1.y >> A.p2.x >> A.p2.y >> B.p1.x >> B.p1.y >>
         B.p2.x >> B.p2.y >> C.p1.x >> C.p1.y >> C.p2.x >> C.p2.y) {
    int com = 0;
    if (A.p1 == B.p1 || A.p1 == B.p2 || A.p2 == B.p1 || A.p2 == B.p2) com = 1;
    if (A.p1 == C.p1 || A.p1 == C.p2 || A.p2 == C.p1 || A.p2 == C.p2) com = 2;
    if (C.p1 == B.p1 || C.p1 == B.p2 || C.p2 == B.p1 || C.p2 == B.p2) com = 3;
    if (com == 2) swap(C, B);
    if (com == 3) swap(C, A);
    if (A.p1 == B.p2) swap(B.p1, B.p2);
    if (A.p2 == B.p1) swap(A.p1, A.p2);
    if (A.p2 == B.p2) swap(A.p1, A.p2), swap(B.p1, B.p2);
    if ((A.p1 - A.p2) * (B.p1 - B.p2) < 0) com = 0;
    if (com == 0 || check() == false)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
