#include <bits/stdc++.h>
using namespace std;
struct punt {
  long long int x, y;
};
bool operator<(punt p1, punt p2) {
  return p1.x < p2.x or (p1.x == p2.x and p1.y < p2.y);
}
bool operator==(punt p1, punt p2) { return p1.x == p2.x and p1.y == p2.y; }
struct segment {
  punt p1, p2;
};
segment llegeix() {
  segment s;
  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
  return s;
}
void escriu(segment s) {
  cout << s.p1.x << " " << s.p1.y << " " << s.p2.x << " " << s.p2.y << endl;
}
bool auncuarto(segment s, punt p) {
  punt v1;
  v1.x = s.p2.x - s.p1.x;
  v1.y = s.p2.y - s.p1.y;
  punt v2;
  v2.x = p.x - s.p1.x;
  v2.y = p.y - s.p1.y;
  long long int prodesc = v1.x * v2.x + v1.y * v2.y;
  long long int prodvect = v1.x * v2.y - v1.y * v2.x;
  if (prodesc <= 0 or prodvect != 0) return false;
  long long int modul1 = v1.x * v1.x + v1.y * v1.y;
  long long int modul2 = v2.x * v2.x + v2.y * v2.y;
  if (100 * modul2 < 2 * 2 * modul1 or 100 * modul2 > 8 * 8 * modul1)
    return false;
  return true;
}
bool igualar(segment &s1, segment &s2) {
  if (s1.p1 == s2.p1) return true;
  if (s1.p1 == s2.p2) {
    swap(s2.p1, s2.p2);
    return true;
  }
  if (s1.p2 == s2.p1) {
    swap(s1.p1, s1.p2);
    return true;
  }
  if (s1.p2 == s2.p2) {
    swap(s1.p1, s1.p2);
    swap(s2.p1, s2.p2);
    return true;
  }
  return false;
}
int main() {
  int casos;
  cin >> casos;
  for (int cas = 0; cas < casos; cas++) {
    segment s1, s2, s3;
    s1 = llegeix();
    s2 = llegeix();
    s3 = llegeix();
    bool ok = false;
    if (igualar(s1, s2)) {
      ok = true;
    } else if (igualar(s1, s3)) {
      swap(s2, s3);
      ok = true;
    } else if (igualar(s2, s3)) {
      swap(s1, s3);
      ok = true;
    }
    if (not ok) {
      cout << "NO" << endl;
    } else {
      punt v1;
      v1.x = s1.p2.x - s1.p1.x;
      v1.y = s1.p2.y - s1.p1.y;
      punt v2;
      v2.x = s2.p2.x - s2.p1.x;
      v2.y = s2.p2.y - s2.p1.y;
      long long int prodesc = v1.x * v2.x + v1.y * v2.y;
      long long int prodvect = v1.x * v2.y - v1.y * v2.x;
      if (prodesc < 0 or prodvect == 0) {
        cout << "NO" << endl;
      } else {
        if (not(auncuarto(s1, s3.p1) or auncuarto(s1, s3.p2))) {
          cout << "NO" << endl;
        } else if (not(auncuarto(s2, s3.p1) or auncuarto(s2, s3.p2))) {
          cout << "NO" << endl;
        } else {
          cout << "YES" << endl;
        }
      }
    }
  }
}
