#include <bits/stdc++.h>
struct point {
  int64_t x, y;
};
struct line {
  point a, b;
};
static bool operator!=(const point &a, const point &b) {
  return a.x != b.x || a.y != b.y;
}
static inline point direction(const line &l) {
  return {l.b.x - l.a.x, l.b.y - l.a.y};
}
static int64_t factorial(const int64_t n) {
  int64_t r = 1;
  for (int64_t i = 1; i <= n; i++) r *= i;
  return r;
}
static bool line_intersection(const line &u, const line &v, int64_t *det,
                              int64_t *s, int64_t *t) {
  const int64_t a = u.b.x - u.a.x, b = v.a.x - v.b.x;
  const int64_t c = u.b.y - u.a.y, d = v.a.y - v.b.y;
  const int64_t p = v.a.x - u.a.x, q = v.a.y - u.a.y;
  const int64_t det_ = a * d - b * c;
  if (det_ == 0) return false;
  if (det != nullptr) *det = det_;
  if (s != nullptr) *s = d * p + -b * q;
  if (t != nullptr) *t = -c * p + a * q;
  return true;
}
static bool all_line_permutations(const line *v, const int n,
                                  std::function<bool(const line *v)> cb) {
  line w[n];
  int p[n];
  for (int i = 0; i < n; i++) p[i] = i;
  for (int i = factorial(n) - 1; 0 <= i; i--) {
    for (int j = 0; j < n; j++) w[j] = v[p[j]];
    for (int k = 0; k < (1 << n); k++) {
      for (int l = 0; l < n; l++)
        if (k & (1 << l)) std::swap(w[l].a, w[l].b);
      if (!cb(w)) return false;
      for (int l = 0; l < n; l++)
        if (k & (1 << l)) std::swap(w[l].a, w[l].b);
    }
    std::next_permutation(&p[0], &p[n]);
  }
  return true;
}
static bool canonical_A(const line v[3]) {
  int64_t d0, t02, t20, d1, t12, t21;
  if (v[0].a != v[1].a) return false;
  const point w0 = direction(v[0]), w1 = direction(v[1]);
  if (w0.x * w1.x + w0.y * w1.y < 0) return false;
  if (!line_intersection(v[0], v[1], NULL, NULL, NULL) ||
      !line_intersection(v[0], v[2], &d0, &t02, &t20) ||
      !line_intersection(v[1], v[2], &d1, &t12, &t21))
    return false;
  return 1 * d0 <= 5 * t02 && 5 * t02 <= 4 * d0 && 0 == t20 &&
         1 * d1 <= 5 * t12 && 5 * t12 <= 4 * d1 && t21 == d1;
}
int main(int argc, char *argv[]) {
  int n;
  if (fscanf(stdin, "%d\n", &n) != 1) {
    fprintf(stderr, "fscanf: Header IO error.\n");
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < n; i++) {
    line v[3] = {};
    for (int j = 0; j < 3; j++) {
      if (fscanf(stdin, "%" SCNd64 " %" SCNd64 " %" SCNd64 " %" SCNd64,
                 &v[j].a.x, &v[j].a.y, &v[j].b.x, &v[j].b.y) != 4) {
        fprintf(stderr, "fscanf: Coordinate IO error.\n");
        exit(EXIT_FAILURE);
      }
    }
    const bool valid = !all_line_permutations(
        v, 3, [](const line *w) { return !canonical_A(w); });
    printf(valid ? "YES\n" : "NO\n");
  }
  return EXIT_SUCCESS;
}
