#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int p[2][2];
  bool onLine(long long int x, long long int y) {
    long long int v1[2], v2[2];
    v1[0] = p[0][0] - x;
    v1[1] = p[0][1] - y;
    v2[0] = p[1][0] - x;
    v2[1] = p[1][1] - y;
    if (v1[0] * v2[1] != v2[0] * v1[1]) return false;
    if (v1[0] * v2[0] > 0) return false;
    if (v1[1] * v2[1] > 0) return false;
    if (v1[0] == 0) v1[0] = v1[1], v2[0] = v2[1];
    if (abs(v1[0]) <= abs(v2[0]) && abs(v1[0]) * 4 >= abs(v2[0])) return true;
    if (abs(v1[0]) >= abs(v2[0]) && abs(v2[0]) * 4 >= abs(v1[0])) return true;
    return false;
  }
};
node l[3];
int main() {
  int t;
  cin >> t;
  while (t--) {
    for (int i = 0; i < 3; i++)
      cin >> l[i].p[0][0] >> l[i].p[0][1] >> l[i].p[1][0] >> l[i].p[1][1];
    bool f = false;
    for (int k = 0; k < 3; k++) {
      node a = l[k], b = l[(k + 1) % 3];
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++)
          if (a.p[i][0] == b.p[j][0] && a.p[i][1] == b.p[j][1]) {
            node c = l[(k + 2) % 3];
            long long int v1[2], v2[2];
            v1[0] = a.p[(i + 1) % 2][0] - a.p[i][0];
            v1[1] = a.p[(i + 1) % 2][1] - a.p[i][1];
            v2[0] = b.p[(j + 1) % 2][0] - b.p[j][0];
            v2[1] = b.p[(j + 1) % 2][1] - b.p[j][1];
            if (v1[0] * v2[0] + v1[1] * v2[1] < 0) continue;
            if (v1[0] * v2[1] == v1[1] * v2[0]) continue;
            if ((a.onLine(c.p[0][0], c.p[0][1]) &&
                 b.onLine(c.p[1][0], c.p[1][1])) ||
                (a.onLine(c.p[1][0], c.p[1][1]) &&
                 b.onLine(c.p[0][0], c.p[0][1]))) {
              f = true;
              break;
            }
          }
    }
    if (f)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
