#include <bits/stdc++.h>
using namespace std;
void prepare() {}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
struct C {
  int x;
  int y;
};
int check(const C a, C b, C c) {
  int g1, g2;
  c.x -= a.x;
  b.x -= a.x;
  c.y -= a.y;
  b.y -= a.y;
  g1 = gcd(abs(b.x), abs(b.y));
  g2 = gcd(abs(c.x), abs(c.y));
  if (g1 == 0 && g2 == 0) return 1;
  if (g1 == 0 || g2 == 0) return 2;
  b.x /= g1;
  b.y /= g1;
  c.x /= g2;
  c.y /= g2;
  if (c.x != b.x || c.y != b.y) return 0;
  g1 *= 5;
  if (g2 <= g1 && g1 <= 4 * g2)
    return 1;
  else
    return 2;
}
long long dist(const C &a, const C &b) {
  return (long long)(b.x - a.x) * (b.x - a.x) +
         (long long)(b.y - a.y) * (b.y - a.y);
}
bool my_check(C a, C b, C c, C d, C e, C f) {
  if (a.x != c.x || a.y != c.y) return false;
  if (check(a, e, b) != 1) return false;
  if (check(c, f, d) != 1) return false;
  long long bd;
  bd = dist(b, d);
  if (dist(a, b) + dist(a, d) < bd) return false;
  return (check(a, b, c) != 0);
}
C q[7];
int w[7];
bool solve() {
  int i;
  for (i = 0; i < 6; i++) {
    scanf("%d%d", &q[i].x, &q[i].y);
    w[i] = i;
  }
  int j, k, t;
  do {
    for (i = 0; i < 2; i++) {
      for (j = 0; j < 2; j++) {
        for (k = 0; k < 2; k++) {
          t = 0;
          if (my_check(q[w[0] * 2], q[w[0] * 2 + 1], q[w[1] * 2],
                       q[w[1] * 2 + 1], q[w[2] * 2], q[w[2] * 2 + 1]))
            return true;
          swap(q[4], q[5]);
        }
        swap(q[2], q[3]);
      }
      swap(q[0], q[1]);
    }
  } while (next_permutation(w, w + 3));
  return false;
}
int main() {
  prepare();
  int i, t;
  scanf("%d", &t);
  for (i = 0; i < t; i++)
    if (solve())
      printf("YES\n");
    else
      printf("NO\n");
  return 0;
}
