#include <bits/stdc++.h>
using namespace std;
const int N = 1003, inf = 2e9;
inline void in(register int &x) {
  int f = 0;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') f |= c == '-', c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  x = f ? -x : x;
}
struct Point {
  long long x, y;
  Point(long long X = 0, long long Y = 0) { x = X, y = Y; }
  inline void In() { scanf("%lld%lld", &x, &y); }
} P1[4], P2[4];
inline long long Dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
inline long long Cro(Point a, Point b) { return a.x * b.y - a.y * b.x; }
inline long long Len(Point a) { return Dot(a, a); }
inline Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); }
inline Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
inline Point operator*(Point a, long long b) { return Point(a.x * b, a.y * b); }
inline bool operator==(Point a, Point b) { return a.x == b.x && a.y == b.y; }
inline bool operator!=(Point a, Point b) { return a.x != b.x || a.y != b.y; }
inline int pan_PL(Point p, Point a, Point b) {
  return !Cro(p - a, p - b) && Dot(p - a, p - b) <= 0;
}
inline int judge(register int i, register int j, register int k) {
  if (!Cro(P2[i] - P1[i], P2[j] - P1[j]) ||
      !Cro(P2[i] - P1[i], P2[k] - P1[k]) || !Cro(P2[j] - P1[j], P2[k] - P1[k]))
    return 0;
  Point P, A;
  register int flag = 0;
  if (P1[i] == P1[j]) flag = 1, P = P1[i];
  if (P1[i] == P2[j]) flag = 1, P = P1[i];
  if (P2[i] == P1[j]) flag = 1, P = P2[i];
  if (P2[i] == P2[j]) flag = 1, P = P2[i];
  if (!flag) return 0;
  if (P1[i] == P) swap(P1[i], P2[i]);
  if (P1[j] == P) swap(P1[j], P2[j]);
  if (Dot(P1[i] - P, P1[j] - P) < 0) return 0;
  if (!pan_PL(P1[k], P, P1[i]) && !pan_PL(P2[k], P, P1[i])) return 0;
  A = pan_PL(P1[k], P, P1[i]) ? P1[k] : P2[k];
  long long len1 = Len(P - A), len2 = Len(P1[i] - A);
  if (len1 > len2) swap(len1, len2);
  if (len1 * 16 < len2) return 0;
  if (!pan_PL(P1[k], P, P1[j]) && !pan_PL(P2[k], P, P1[j])) return 0;
  A = pan_PL(P1[k], P, P1[j]) ? P1[k] : P2[k];
  len1 = Len(P - A), len2 = Len(P1[j] - A);
  if (len1 > len2) swap(len1, len2);
  if (len1 * 16 < len2) return 0;
  return 1;
}
inline int sakura() {
  return judge(3, 2, 1) || judge(1, 3, 2) || judge(1, 2, 3);
}
int T;
int main() {
  in(T);
  while (T--) {
    for (register int i = 1; i <= 3; ++i) P1[i].In(), P2[i].In();
    puts(sakura() ? "YES" : "NO");
  }
}
