#include <bits/stdc++.h>
using namespace std;
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 1000000007;
  if (b & 1) ns = ns * a % 1000000007;
  return ns;
}
struct pt {
  int x, y;
  pt() { ; }
  void rd() { cin >> x >> y; }
  bool operator==(const pt &r) const { return x == r.x && y == r.y; }
} u[3][2];
long long sqr(int a) { return 1ll * a * a; }
long long dis(pt a, pt b) { return sqr(a.x - b.x) + sqr(a.y - b.y); }
bool check(long long a, long long b, long long c) {
  if (c < a + b) return 0;
  c -= (a + b);
  return c * c == 4 * a * b;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    for (int i = 0; i < 3; i++) u[i][0].rd(), u[i][1].rd();
    vector<pair<int, int> > cur;
    for (int i = 0; i < 3; i++)
      for (int j = i + 1; j < 3; j++) {
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            if (u[i][k] == u[j][l]) cur.push_back(make_pair(i, j));
      }
    if (cur.size() != 1)
      cout << "NO" << endl;
    else {
      int i = cur[0].first, j = cur[0].second;
      int e = 3 - i - j;
      int f, g;
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          if (u[i][k] == u[j][l]) f = k, g = l;
      long long d1 = dis(u[i][f], u[i][f ^ 1]), d2 = dis(u[j][g], u[j][g ^ 1]),
                d3 = dis(u[i][f ^ 1], u[j][g ^ 1]);
      if (d1 + d2 < d3)
        cout << "NO" << endl;
      else {
        if (check(d1, d2, d3) || check(d1, d3, d2) || check(d2, d3, d1))
          cout << "NO" << endl;
        else {
          int pl = 0;
          int fl = 0;
          for (int m = 0; m < 2; m++) {
            int cf = 0;
            long long d1 = dis(u[i][0], u[e][m]), d2 = dis(u[i][1], u[e][m]),
                      d3 = dis(u[i][0], u[i][1]);
            if (check(d1, d2, d3) && max(d1, d2) <= 16 * min(d1, d2))
              cf = 1;
            else {
              d1 = dis(u[j][0], u[e][m]), d2 = dis(u[j][1], u[e][m]),
              d3 = dis(u[j][0], u[j][1]);
              if (check(d1, d2, d3) && max(d1, d2) <= 16 * min(d1, d2)) cf = 2;
            }
            fl ^= cf;
          }
          if (fl != 3)
            cout << "NO" << endl;
          else
            cout << "YES" << endl;
        }
      }
    }
  }
  return 0;
}
