#include <bits/stdc++.h>
using namespace std;
int x1[4], x2[4], y1_[4], y2[4];
const double EPS = 10e-9;
const double PI = acos(-1);
inline bool Zero(double X) { return fabs(X) < EPS; }
struct Point {
  double x, y;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
  bool operator<(Point &P) { return Zero(x - P.x) ? y < P.y : x < P.x; }
  bool operator==(Point &P) { return Zero(x - P.x) && Zero(y - P.y); }
  Point operator-(Point &P) { return Point(x - P.x, y - P.y); }
};
struct Line {
  Point A, B;
  Line() {}
  Line(Point A, Point B) : A(A), B(B) {}
};
inline double crossProduct(const Point &A, const Point &B) {
  return A.x * B.y - A.y * B.x;
}
inline bool PntInRect(Point A, Point B, Point P) {
  return min(A.x, B.x) <= P.x && P.x <= max(A.x, B.x) && min(A.y, B.y) <= P.y &&
         P.y <= max(A.y, B.y);
}
inline bool PntInSeg(Line S, Point P) {
  return Zero(crossProduct(S.B - S.A, P - S.A)) && PntInRect(S.A, S.B, P);
}
inline double kw(double X) { return X * X; }
inline double dist(Point A, Point B) {
  return sqrt(kw(A.x - B.x) + kw(A.y - B.y));
}
bool c1(Point a, Point b, Point c) {
  double a1 = dist(a, c);
  double a2 = dist(b, c);
  return (a1 * 4 + EPS >= a2 && a2 * 4 + EPS >= a1);
}
bool check(int a, int b, int c) {
  if (x1[a] != x1[b]) return false;
  if (y1_[a] != y1_[b]) return false;
  double k1 = atan2(y2[a] - y1_[a], x2[a] - x1[a]);
  double k2 = atan2(y2[b] - y1_[b], x2[b] - x1[b]);
  if (Zero(k1 - k2)) return false;
  if (fmod(k2 - k1 + 2 * PI, 2 * PI) > PI / 2 + EPS) return false;
  if (!PntInSeg(Line(Point(x1[a], y1_[a]), Point(x2[a], y2[a])),
                Point(x1[c], y1_[c])))
    return false;
  if (!PntInSeg(Line(Point(x1[b], y1_[b]), Point(x2[b], y2[b])),
                Point(x2[c], y2[c])))
    return false;
  return c1(Point(x1[a], y1_[a]), Point(x2[a], y2[a]), Point(x1[c], y1_[c])) &&
         c1(Point(x1[b], y1_[b]), Point(x2[b], y2[b]), Point(x2[c], y2[c]));
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    for (int(i) = (0); (i) < (3); (i)++)
      scanf("%d %d %d %d", &x1[i], &y1_[i], &x2[i], &y2[i]);
    vector<int> t(3);
    t[0] = 0;
    t[1] = 1;
    t[2] = 2;
    do {
      for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 3; j++)
          if (i & (1 << j)) {
            swap(x1[j], x2[j]);
            swap(y1_[j], y2[j]);
          }
        if (check(t[0], t[1], t[2])) {
          printf("YES\n");
          goto end;
        }
        for (int j = 0; j < 3; j++)
          if (i & (1 << j)) {
            swap(x1[j], x2[j]);
            swap(y1_[j], y2[j]);
          }
      }
    } while (next_permutation(t.begin(), t.end()));
    printf("NO\n");
  end:;
  }
  return 0;
}
