#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const long double pi = 2 * acos(0);
int T, n, i, j, k, l, p, g;
struct node {
  long long x, y;
} a[5][3], z[10];
node operator-(node a, node b) { return (node){a.x - b.x, a.y - b.y}; }
long double dis(node a) { return sqrt(((a.x) * (a.x)) + ((a.y) * (a.y))); }
bool pdj(node a, node b) {
  long double t = acos((a.x * b.x + a.y * b.y) / dis(a) / dis(b));
  return t > 0 && t <= pi / 2 + 1e-12;
}
bool same(node a, node b) { return a.x == b.x && a.y == b.y; }
void read(node& a) { read(a.x, a.y); }
long long mul(node a, node b) { return a.x * b.y - a.y * b.x; }
bool on(node a, node b, node c) {
  long long d1 = b.x - a.x, d2 = b.y - a.y, d3 = c.x - b.x, d4 = c.y - b.y;
  return d1 * d4 == d2 * d3;
}
bool in(node a, node b, node c) {
  if (mul(a - b, c - b) == 0 && a.x >= min(b.x, c.x) && a.x <= max(b.x, c.x) &&
      a.y >= min(b.y, c.y) && a.y <= max(b.y, c.y)) {
    long double A = dis(a - b), B = dis(a - c);
    if (A > B) swap(A, B);
    if (A / B >= 0.25) return 1;
  }
  return 0;
}
bool ddd() {
  if (same(a[1][0], a[2][0]))
    ;
  else if (same(a[1][0], a[2][1]))
    swap(a[2][0], a[2][1]);
  else
    return 0;
  if (!pdj(a[1][1] - a[1][0], a[2][1] - a[1][0])) return 0;
  if (in(a[3][0], a[1][0], a[1][1]) && in(a[3][1], a[2][0], a[2][1])) return 1;
  if (in(a[3][1], a[1][0], a[1][1]) && in(a[3][0], a[2][0], a[2][1])) return 1;
  return 0;
}
bool solve() {
  bool tt = ddd();
  swap(a[1][0], a[1][1]);
  tt |= ddd();
  return tt;
}
int main() {
  int cnt = 0, vv;
  for (read(T), vv = T; T; T--) {
    int g = 0;
    for (i = 1; i <= 3; i++)
      read(a[i][0]), read(a[i][1]), z[++g] = a[i][0], z[++g] = a[i][1];
    bool pd = 0;
    pd |= solve();
    swap(a[1][0], a[3][0]);
    swap(a[1][1], a[3][1]);
    pd |= solve();
    swap(a[2][0], a[3][0]);
    swap(a[2][1], a[3][1]);
    pd |= solve();
    if (pd)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
