#include <bits/stdc++.h>
using namespace std;
long long len(long long x, long long y) { return x * x + y * y; }
long long scal(long long x1, long long y1, long long x2, long long y2) {
  if (x1 * y2 == x2 * y1) return -1;
  return x1 * x2 + y1 * y2;
}
bool in(long long x1, long long y1, long long x2, long long y2, long long x,
        long long y) {
  long long vx = x1 - x;
  long long vy = y1 - y;
  long long wx = x2 - x;
  long long wy = y2 - y;
  if (vx * wy == vy * wx && vx * wx + vy * wy < 0) return true;
  return false;
}
bool sootn(long long x1, long long y1, long long x2, long long y2, long long x,
           long long y) {
  long long vx = x - x1;
  long long vy = y - y1;
  long long wx = x - x2;
  long long wy = y - y2;
  long long l1 = len(vx, vy);
  long long l2 = len(wx, wy);
  if (l1 >= l2)
    return (16 * l2 >= l1);
  else
    return (16 * l1 >= l2);
}
int Solution() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    long long x[6], y[6];
    for (int j = 0; j < 6; ++j) scanf("%I64d%I64d", &x[j], &y[j]);
    int ind = -1;
    for (int j = 0; j < 6; ++j)
      for (int k = j + 1; k < 6; ++k)
        if (x[j] == x[k] && y[j] == y[k]) {
          ind = j;
          break;
        }
    if (ind == -1) {
      printf("NO\n");
      continue;
    }
    int ind1 = -1, ind2;
    for (int j = 0; j < 6; ++j)
      if (x[j] == x[ind] && y[j] == y[ind])
        if (ind1 == -1)
          ind1 = j;
        else
          ind2 = j;
    if (ind1 & 1)
      ind1--;
    else
      ind1++;
    if (ind2 & 1)
      ind2--;
    else
      ind2++;
    long long an = scal(x[ind1] - x[ind], y[ind1] - y[ind], x[ind2] - x[ind],
                        y[ind2] - y[ind]);
    if (an < 0) {
      printf("NO\n");
      continue;
    }
    int num3 = 3 - ind1 / 2 - ind2 / 2;
    if (in(x[ind], y[ind], x[ind1], y[ind1], x[num3 * 2], y[num3 * 2]) &&
        in(x[ind], y[ind], x[ind2], y[ind2], x[num3 * 2 + 1],
           y[num3 * 2 + 1])) {
      bool soot =
          sootn(x[ind], y[ind], x[ind1], y[ind1], x[num3 * 2], y[num3 * 2]);
      if (!soot) {
        printf("NO\n");
        continue;
      }
      soot = sootn(x[ind], y[ind], x[ind2], y[ind2], x[num3 * 2 + 1],
                   y[num3 * 2 + 1]);
      if (!soot) {
        printf("NO\n");
        continue;
      }
    } else if (in(x[ind], y[ind], x[ind1], y[ind1], x[num3 * 2 + 1],
                  y[num3 * 2 + 1]) &&
               in(x[ind], y[ind], x[ind2], y[ind2], x[num3 * 2], y[num3 * 2])) {
      bool soot = sootn(x[ind], y[ind], x[ind1], y[ind1], x[num3 * 2 + 1],
                        y[num3 * 2 + 1]);
      if (!soot) {
        printf("NO\n");
        continue;
      }
      soot = sootn(x[ind], y[ind], x[ind2], y[ind2], x[num3 * 2], y[num3 * 2]);
      if (!soot) {
        printf("NO\n");
        continue;
      }
    } else {
      printf("NO\n");
      continue;
    }
    printf("YES\n");
  }
  return 0;
}
int main() {
  Solution();
  return 0;
}
