#include <bits/stdc++.h>
int ok(int x, int y, int x1, int y1, int x2, int y2) {
  int com1 = x - x2;
  int com2 = y - y2;
  int com3 = x1 - x2;
  int com4 = y1 - y2;
  if (com4 * com1 == com2 * com3) {
    if (x2 != x1 && x != x2) {
      double com = double(x - x2) / (x2 - x1);
      if (com >= 0.25 && com <= 4) return 1;
    } else {
      double com = double(y - y2) / (y2 - y1);
      if (com >= 0.25 && com <= 4) return 1;
    }
  }
  return 0;
}
int ok1(int x, int y, int x1, int y1, int x2, int y2) {
  long long com1 = x - x2;
  long long com2 = y - y2;
  long long com3 = x1 - x2;
  long long com4 = y1 - y2;
  long long com5 = x1 - x;
  long long com6 = y1 - y;
  if ((com1 * com1 + com2 * com2 + com3 * com3 + com4 * com4) >=
          (com5 * com5 + com6 * com6) &&
      (com5 * com5 + com6 * com6) > 0)
    return 1;
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int x[6], y[6];
    int x1[5], y1[5];
    int flag[6] = {0};
    for (int i = 0; i < 6; i++) scanf("%d%d", &x[i], &y[i]);
    for (int i = 0; i < 6; i++)
      for (int j = i + 1; j < 6; j++)
        if (x[i] == x[j] && y[i] == y[j]) {
          flag[i] = 1;
          flag[j] = 1;
          x1[0] = x[i];
          y1[0] = y[i];
          flag[i ^ 1] = 1;
          flag[j ^ 1] = 1;
          x1[1] = x[i ^ 1];
          y1[1] = y[i ^ 1];
          x1[2] = x[j ^ 1];
          y1[2] = y[j ^ 1];
          break;
        }
    int j = 3;
    for (int i = 0; i < 6; i++) {
      if (flag[i] == 0) {
        x1[j] = x[i];
        y1[j++] = y[i];
      }
    }
    int f = 0;
    if (ok1(x1[3], y1[3], x1[4], y1[4], x1[0], y1[0])) {
      if (ok(x1[0], y1[0], x1[1], y1[1], x1[3], y1[3]) &&
          ok(x1[0], y1[0], x1[2], y1[2], x1[4], y1[4])) {
        f = 1;
        printf("YES\n");
      }
      if (ok(x1[0], y1[0], x1[2], y1[2], x1[3], y1[3]) &&
          ok(x1[0], y1[0], x1[1], y1[1], x1[4], y1[4])) {
        f = 1;
        printf("YES\n");
      }
    }
    if (!f) printf("NO\n");
  }
}
