#include <bits/stdc++.h>
using namespace std;
long long x[4], y[4], z[4];
void read(long long x[]) {
  for (int i = 0; i < 4; i++) {
    int p;
    scanf("%d", &p);
    x[i] = p;
  }
}
double dist(double x, double y, double z, double t) {
  return sqrt((x - z) * (x - z) + (y - t) * (y - t));
}
int solve() {
  int f = 0, s = 0;
  if (x[0] == y[0] && x[1] == y[1]) f = 1, s = 2;
  if (x[2] == y[2] && x[3] == y[3]) f = 1, s = 2;
  if (x[0] == y[2] && x[1] == y[3]) f = 1, s = 2;
  if (x[2] == y[0] && x[3] == y[1]) f = 1, s = 2;
  if (z[0] == y[0] && z[1] == y[1]) f = 2, s = 3;
  if (z[2] == y[2] && z[3] == y[3]) f = 2, s = 3;
  if (z[0] == y[2] && z[1] == y[3]) f = 2, s = 3;
  if (z[2] == y[0] && z[3] == y[1]) f = 2, s = 3;
  if (x[0] == z[0] && x[1] == z[1]) f = 1, s = 3;
  if (x[2] == z[2] && x[3] == z[3]) f = 1, s = 3;
  if (x[0] == z[2] && x[1] == z[3]) f = 1, s = 3;
  if (x[2] == z[0] && x[3] == z[1]) f = 1, s = 3;
  if (f == 0 && s == 0) return 0;
  long long p[4][4];
  for (int i = 0; i < 4; i++) p[1][i] = x[i], p[2][i] = y[i], p[3][i] = z[i];
  if (f != 1)
    for (int i = 0; i < 4; i++) swap(p[1][i], p[f][i]);
  if (s != 2)
    for (int i = 0; i < 4; i++) swap(p[2][i], p[s][i]);
  double A = dist(p[1][0], p[1][1], p[1][2], p[1][3]);
  double B = dist(p[2][0], p[2][1], p[2][2], p[2][3]);
  double C;
  if (p[1][0] == p[2][0] && p[1][1] == p[2][1])
    C = dist(p[1][2], p[1][3], p[2][2], p[2][3]);
  if (p[1][0] == p[2][2] && p[1][1] == p[2][3])
    C = dist(p[1][2], p[1][3], p[2][0], p[2][1]);
  if (p[1][2] == p[2][0] && p[1][3] == p[2][1])
    C = dist(p[1][0], p[1][1], p[2][2], p[2][3]);
  if (p[1][2] == p[2][2] && p[1][3] == p[2][3])
    C = dist(p[1][0], p[1][1], p[2][0], p[2][1]);
  double co = (A * A + B * B - C * C) / 2.0 / A / B;
  if (co >= 0 && co < 1) {
    long long AA, BB, CC;
    AA = p[1][1] - p[1][3];
    BB = p[1][2] - p[1][0];
    CC = p[1][0] * p[1][3] - p[1][1] * p[1][2];
    if (AA * p[3][0] + BB * p[3][1] + CC != 0 &&
        AA * p[3][2] + BB * p[3][3] + CC != 0)
      return 0;
    if (AA * p[3][0] + BB * p[3][1] + CC == 0) {
      double A1 = dist(p[3][0], p[3][1], p[1][0], p[1][1]);
      double B1 = dist(p[3][0], p[3][1], p[1][2], p[1][3]);
      if (A1 > A || B1 > A) return 0;
      if (A1 > B1) swap(A1, B1);
      if (A1 / B1 < 0.25) return 0;
      A1 = dist(p[3][2], p[3][3], p[2][0], p[2][1]);
      B1 = dist(p[3][2], p[3][3], p[2][2], p[2][3]);
      if (fabs(A1 + B1 - B) > 1e-8) return 0;
      if (A1 > B1) swap(A1, B1);
      if (A1 / B1 < 0.25) return 0;
      return 1;
    }
    if (AA * p[3][2] + BB * p[3][3] + CC == 0) {
      double A1 = dist(p[3][2], p[3][3], p[1][0], p[1][1]);
      double B1 = dist(p[3][2], p[3][3], p[1][2], p[1][3]);
      if (A1 > A || B1 > A) return 0;
      if (A1 > B1) swap(A1, B1);
      if (A1 / B1 < 0.25) return 0;
      A1 = dist(p[3][0], p[3][1], p[2][0], p[2][1]);
      B1 = dist(p[3][0], p[3][1], p[2][2], p[2][3]);
      if (fabs(A1 + B1 - B) > 1e-8) return 0;
      if (A1 > B1) swap(A1, B1);
      if (A1 / B1 < 0.25) return 0;
      return 1;
    }
  }
  return 0;
}
int main() {
  int t;
  scanf("%d", &t);
  for (int tt = 0; tt < t; tt++) {
    read(x), read(y), read(z);
    int res = solve();
    if (res)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
