#include <bits/stdc++.h>
using namespace std;
int const uu[4] = {1, -1, 0, 0};
int const vv[4] = {0, 0, 1, -1};
int const inf = 0x3f3f3f3f;
long long const INF = 0x7fffffffffffffffll;
double eps = 1e-10;
double pi = acos(-1.0);
struct Point {
  double x, y;
};
struct segment {
  Point a, b;
} S[5];
bool samePoint(Point a, Point b) {
  if (fabs(a.x - b.x) < eps && fabs(a.y - b.y) < eps) {
    return true;
  }
  return false;
}
bool PointOnSegment(Point a, segment L) {
  if ((a.x - L.a.x) * (L.b.y - L.a.y) == (a.y - L.a.y) * (L.b.x - L.a.x) &&
      min(L.a.x, L.b.x) <= a.x && a.x <= max(L.a.x, L.b.x) &&
      min(L.a.y, L.b.y) <= a.y && a.y <= max(L.a.y, L.b.y)) {
    return true;
  }
  return false;
}
double rates(Point a, segment L) {
  double l1 = (a.x - L.a.x) * (a.x - L.a.x) + (a.y - L.a.y) * (a.y - L.a.y);
  double l2 = (a.x - L.b.x) * (a.x - L.b.x) + (a.y - L.b.y) * (a.y - L.b.y);
  if (l1 < eps || l2 < eps) {
    return 999999.0;
  }
  if (l1 < l2) {
    return l2 / l1;
  } else {
    return l1 / l2;
  }
}
long long Cos(double x1, double y1, double x2, double y2) {
  if (x1 * x2 + y1 * y2 >= 0) {
    return true;
  }
  return false;
}
bool solve() {
  bool t1 = samePoint(S[1].a, S[2].a);
  bool t2 = samePoint(S[1].a, S[2].b);
  bool t3 = samePoint(S[1].b, S[2].a);
  bool t4 = samePoint(S[1].b, S[2].b);
  if (t1 || t2 || t3 || t4) {
    bool flag = false;
    if (t1) {
      double x1, y1, x2, y2;
      x1 = S[1].b.x - S[1].a.x;
      y1 = S[1].b.y - S[1].a.y;
      x2 = S[2].b.x - S[2].a.x;
      y2 = S[2].b.y - S[2].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t2) {
      double x1, y1, x2, y2;
      x1 = S[1].b.x - S[1].a.x;
      y1 = S[1].b.y - S[1].a.y;
      x2 = S[2].a.x - S[2].b.x;
      y2 = S[2].a.y - S[2].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t3) {
      double x1, y1, x2, y2;
      x1 = S[1].a.x - S[1].b.x;
      y1 = S[1].a.y - S[1].b.y;
      x2 = S[2].b.x - S[2].a.x;
      y2 = S[2].b.y - S[2].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t4) {
      double x1, y1, x2, y2;
      x1 = S[1].a.x - S[1].b.x;
      y1 = S[1].a.y - S[1].b.y;
      x2 = S[2].a.x - S[2].b.x;
      y2 = S[2].a.y - S[2].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (flag) {
      if (PointOnSegment(S[3].a, S[1]) && PointOnSegment(S[3].b, S[2])) {
        if (rates(S[3].a, S[1]) <= 16.0 && rates(S[3].b, S[2]) <= 16.0) {
          return true;
        }
      }
      if (PointOnSegment(S[3].b, S[1]) && PointOnSegment(S[3].a, S[2])) {
        if (rates(S[3].b, S[1]) <= 16.0 && rates(S[3].a, S[2]) <= 16.0) {
          return true;
        }
      }
    }
  }
  t1 = samePoint(S[1].a, S[3].a);
  t2 = samePoint(S[1].a, S[3].b);
  t3 = samePoint(S[1].b, S[3].a);
  t4 = samePoint(S[1].b, S[3].b);
  if (t1 || t2 || t3 || t4) {
    bool flag = false;
    if (t1) {
      double x1, y1, x2, y2;
      x1 = S[1].b.x - S[1].a.x;
      y1 = S[1].b.y - S[1].a.y;
      x2 = S[3].b.x - S[3].a.x;
      y2 = S[3].b.y - S[3].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t2) {
      double x1, y1, x2, y2;
      x1 = S[1].b.x - S[1].a.x;
      y1 = S[1].b.y - S[1].a.y;
      x2 = S[3].a.x - S[3].b.x;
      y2 = S[3].a.y - S[3].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t3) {
      double x1, y1, x2, y2;
      x1 = S[1].a.x - S[1].b.x;
      y1 = S[1].a.y - S[1].b.y;
      x2 = S[3].b.x - S[3].a.x;
      y2 = S[3].b.y - S[3].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t4) {
      double x1, y1, x2, y2;
      x1 = S[1].a.x - S[1].b.x;
      y1 = S[1].a.y - S[1].b.y;
      x2 = S[3].a.x - S[3].b.x;
      y2 = S[3].a.y - S[3].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (flag) {
      if (PointOnSegment(S[2].a, S[1]) && PointOnSegment(S[2].b, S[3])) {
        if (rates(S[2].a, S[1]) <= 16.0 && rates(S[2].b, S[3]) <= 16.0) {
          return true;
        }
      }
      if (PointOnSegment(S[2].b, S[1]) && PointOnSegment(S[2].a, S[3])) {
        if (rates(S[2].b, S[1]) <= 16.0 && rates(S[2].a, S[3]) <= 16.0) {
          return true;
        }
      }
    }
  }
  t1 = samePoint(S[2].a, S[3].a);
  t2 = samePoint(S[2].a, S[3].b);
  t3 = samePoint(S[2].b, S[3].a);
  t4 = samePoint(S[2].b, S[3].b);
  if (t1 || t2 || t3 || t4) {
    bool flag = false;
    if (t1) {
      double x1, y1, x2, y2;
      x1 = S[2].b.x - S[2].a.x;
      y1 = S[2].b.y - S[2].a.y;
      x2 = S[3].b.x - S[3].a.x;
      y2 = S[3].b.y - S[3].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t2) {
      double x1, y1, x2, y2;
      x1 = S[2].b.x - S[2].a.x;
      y1 = S[2].b.y - S[2].a.y;
      x2 = S[3].a.x - S[3].b.x;
      y2 = S[3].a.y - S[3].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t3) {
      double x1, y1, x2, y2;
      x1 = S[2].a.x - S[2].b.x;
      y1 = S[2].a.y - S[2].b.y;
      x2 = S[3].b.x - S[3].a.x;
      y2 = S[3].b.y - S[3].a.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (t4) {
      double x1, y1, x2, y2;
      x1 = S[2].a.x - S[2].b.x;
      y1 = S[2].a.y - S[2].b.y;
      x2 = S[3].a.x - S[3].b.x;
      y2 = S[3].a.y - S[3].b.y;
      if (Cos(x1, y1, x2, y2)) {
        flag = true;
      }
    }
    if (flag) {
      if (PointOnSegment(S[1].a, S[2]) && PointOnSegment(S[1].b, S[3])) {
        if (rates(S[1].a, S[2]) <= 16.0 && rates(S[1].b, S[3]) <= 16.0) {
          return true;
        }
      }
      if (PointOnSegment(S[1].b, S[2]) && PointOnSegment(S[1].a, S[3])) {
        if (rates(S[1].b, S[2]) <= 16.0 && rates(S[1].a, S[3]) <= 16.0) {
          return true;
        }
      }
    }
  }
  return false;
}
int T;
int main() {
  cin >> T;
  while (T--) {
    scanf("%lf%lf%lf%lf", &S[1].a.x, &S[1].a.y, &S[1].b.x, &S[1].b.y);
    scanf("%lf%lf%lf%lf", &S[2].a.x, &S[2].a.y, &S[2].b.x, &S[2].b.y);
    scanf("%lf%lf%lf%lf", &S[3].a.x, &S[3].a.y, &S[3].b.x, &S[3].b.y);
    if (solve()) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}
