#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
};
point s[3][2];
bool pequal(point a, point b) {
  if (a.x == b.x && a.y == b.y)
    return true;
  else
    return false;
}
point subt(point a, point b) {
  point tem;
  tem.x = a.x - b.x;
  tem.y = a.y - b.y;
  return tem;
}
double xmult(point a, point b) { return (double)a.x * b.x + a.y * b.y; }
double molength(point a) {
  return sqrt((double)((a.x) * (a.x)) + ((a.y) * (a.y)));
}
double calcangle(point a, point b) {
  return xmult(a, b) / molength(a) / molength(b);
}
bool sameendpointangle(long long a, long long b) {
  long long i, j;
  double cv;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++)
      if (pequal(s[a][i], s[b][j]) && !pequal(s[a][1 - i], s[b][1 - j])) {
        cv = calcangle(subt(s[a][1 - i], s[a][i]), subt(s[b][1 - j], s[b][j]));
        if (cv >= 0 - 1e-8) return true;
      }
  return false;
}
bool inaline(point a, point b, point c) {
  if ((a.x - b.x) * (a.y - c.y) == (a.y - b.y) * (a.x - c.x))
    return true;
  else
    return false;
}
bool portionright(point a, point b) {
  if (xmult(a, b) * 5 >= xmult(b, b) && xmult(a, b) * 5 <= 4 * xmult(b, b))
    return true;
  else
    return false;
}
bool divideportion(int a, point p) {
  double tem;
  if (inaline(s[a][0], s[a][1], p)) {
    if (portionright(subt(s[a][0], p), subt(s[a][0], s[a][1]))) return true;
  }
  return false;
}
bool connectportion(int a, int b, int c) {
  if ((divideportion(a, s[c][0]) && divideportion(b, s[c][1])) ||
      (divideportion(b, s[c][0]) && divideportion(a, s[c][1])))
    return true;
  else
    return false;
}
bool judge(void) {
  long long i, j, third;
  for (i = 0; i < 3; i++)
    for (j = i + 1; j < 3; j++) {
      third = 3 - i - j;
      if (sameendpointangle(i, j) && connectportion(i, j, third)) return true;
    }
  return false;
}
int main() {
  long long tn, i, j;
  scanf("%I64d", &tn);
  while (tn--) {
    for (i = 0; i < 3; i++)
      for (j = 0; j < 2; j++) scanf("%I64d%I64d", &s[i][j].x, &s[i][j].y);
    if (judge())
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
