#include <bits/stdc++.h>
using namespace std;
bool angle(pair<long long, long long>& A, pair<long long, long long>& B,
           pair<long long, long long>& C) {
  pair<long long, long long> AB = make_pair(B.first - A.first,
                                            B.second - A.second),
                             AC = make_pair(C.first - A.first,
                                            C.second - A.second);
  return AB.first * AC.first + AB.second * AC.second >= 0;
}
bool onLine(pair<long long, long long>& D, pair<long long, long long>& A,
            pair<long long, long long>& B) {
  if ((B.second - A.second) * (D.first - A.first) ==
      (D.second - A.second) * (B.first - A.first)) {
    long long yab = B.second - A.second, yad = D.second - A.second;
    if (yab) {
      long double ratio = (long double)yad * 1.0 / (long double)yab;
      if (ratio < (long double)0.8 + 1e-9 && ratio > (long double)0.20 - 1e-9) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  long long t = 0, x1 = 0, x2 = 0, y1 = 0, y2 = 0;
  cin >> t;
  for (int i = 1; i <= t; ++i) {
    map<pair<long long, long long>, set<pair<long long, long long>>> cMap;
    pair<long long, long long> head = make_pair(1e9, 1e9);
    for (int j = 1; j <= 3; ++j) {
      cin >> x1 >> y1 >> x2 >> y2;
      pair<long long, long long> p1 = make_pair(x1, y1), p2 = make_pair(x2, y2);
      cMap[p1].insert(p2);
      cMap[p2].insert(p1);
      if (cMap[p1].size() == 2) {
        head = p1;
      } else if (cMap[p2].size() == 2) {
        head = p2;
      }
    }
    if (cMap.size() != 5 || head.first == 1e9) {
      cout << "NO" << endl;
    } else {
      pair<long long, long long> B = *cMap[head].begin(),
                                 C = *cMap[head].rbegin();
      cMap.erase(B);
      cMap.erase(C);
      cMap.erase(head);
      if (angle(head, B, C)) {
        pair<long long, long long> D, E;
        for (auto m : cMap) {
          D = m.first;
          break;
        }
        E = *(cMap[D].begin());
        if ((onLine(D, head, B) && onLine(E, head, C)) ||
            (onLine(E, head, B) && onLine(D, head, C))) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      } else {
        cout << "NO" << endl;
      }
    }
  }
  return 0;
}
