#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
  Point(int xx = 0, int yy = 0) {
    x = xx;
    y = yy;
  }
  bool operator!=(Point p) { return x != p.x || y != p.y; }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  long long operator*(Point op) {
    return (long long)x * op.x + (long long)y * op.y;
  }
  long long operator%(Point op) {
    return (long long)x * op.y - (long long)y * op.x;
  }
};
struct Segment {
  Point start, end;
  void Swap() { swap(start, end); }
};
int Sign(long long x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
bool Check15(Point A, Point B) {
  int da, db;
  if (A.x == 0 && B.x == 0) {
    da = A.y;
    db = B.y;
  } else {
    da = A.x;
    db = B.x;
  }
  if (Sign(da) * Sign(db) == -1) return false;
  if (Sign(da) == -1 || Sign(db) == -1) {
    da *= -1;
    db *= -1;
  }
  return (da <= 5 * db && 5 * db <= 4 * da);
}
bool CheckA2(Segment a, Segment b, Segment c) {
  if (a.start != b.start) return false;
  Point A = a.end - a.start;
  Point B = b.end - b.start;
  Point C = c.start - a.start;
  Point D = c.end - a.start;
  if (!(A * B >= 0 && A % B != 0)) return false;
  if (C % A != 0 || D % B != 0) return false;
  if (!Check15(A, C) || !Check15(B, D)) return false;
  return true;
}
bool CheckA(Segment a, Segment b, Segment c) {
  for (int ia = 0; ia < 2; ++ia) {
    for (int ib = 0; ib < 2; ++ib) {
      for (int ic = 0; ic < 2; ++ic) {
        if (CheckA2(a, b, c)) return true;
        c.Swap();
      }
      b.Swap();
    }
    a.Swap();
  }
  return false;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    Segment segments[3];
    for (int i = 0; i < 3; ++i) {
      scanf("%d%d", &segments[i].start.x, &segments[i].start.y);
      scanf("%d%d", &segments[i].end.x, &segments[i].end.y);
    }
    bool res = false;
    int order[] = {0, 1, 2};
    do {
      res |= CheckA(segments[order[0]], segments[order[1]], segments[order[2]]);
    } while (next_permutation(order, order + 3));
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}
