#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  void operator-=(Point points) {
    x -= points.x;
    y -= points.y;
  }
  bool operator==(Point points) { return x == points.x && y == points.y; }
  double operator*(Point points) { return x * points.x + y * points.y; }
  double operator%(Point points) { return x * points.y - y * points.x; }
};
struct Line {
  Point a, b;
} s[3];
bool pointTest(Point x, Point y) {
  long long a = (x * y);
  long long b = (y * y);
  return x % y == 0 && b <= 5 * a && 5 * a <= 4 * b;
}
bool lineTest(Line d, Line e, Line f) {
  e.b -= e.a;
  f.b -= f.a;
  d.a -= e.a;
  d.b -= f.a;
  return e.a == f.a && e.b % f.b != 0 && e.b * f.b >= 0 &&
         pointTest(d.a, e.b) && pointTest(d.b, f.b);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int h = 0; h < 3; h++) {
      cin >> s[h].a.x >> s[h].a.y >> s[h].b.x >> s[h].b.y;
    }
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          for (int m = 0; m < 3; m++) {
            if (lineTest(s[m], s[(m + 1) % 3], s[(m + 2) % 3])) {
              cout << "YES" << endl;
              goto NEXT;
            }
          }
          swap(s[2].a, s[2].b);
        }
        swap(s[1].a, s[1].b);
      }
      swap(s[0].a, s[0].b);
    }
    cout << "NO" << endl;
  NEXT:
    continue;
  }
  return 0;
}
