#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point() {}
  point(long long _x, long long _y) {
    x = _x;
    y = _y;
  }
  void scan() { scanf("%I64d %I64d", &x, &y); }
  void swap(point &p) {
    point s = *this;
    *this = p;
    p = s;
  }
  point operator-(const point &p) const { return point(x - p.x, y - p.y); }
  bool operator==(const point &p) const { return x == p.x && y == p.y; }
};
long long VP(point a, point b, point c) {
  return a.x * b.y + a.y * c.x + b.x * c.y - b.y * c.x - a.x * c.y - a.y * b.x;
}
long long SP(point a, point b, point c) {
  point v1 = a - b;
  point v2 = c - b;
  return v1.x * v2.x + v1.y * v2.y;
}
long long dist2(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
struct segment {
  point begin, end;
  void scan() {
    begin.scan();
    end.scan();
  }
  void swap(segment &s) {
    segment p = *this;
    *this = s;
    s = p;
  }
  void swapEndpoints() { begin.swap(end); }
  bool hold(point p) {
    if (VP(begin, p, end) != 0) return false;
    long long minX = min(begin.x, end.x);
    long long maxX = max(begin.x, end.x);
    long long minY = min(begin.y, end.y);
    long long maxY = max(begin.y, end.y);
    return minX <= p.x && p.x <= maxX && minY <= p.y && p.y <= maxY;
  }
  bool good(point p) {
    if (!hold(p)) return false;
    long long x = dist2(begin, p);
    long long y = dist2(p, end);
    if (x > y) {
      long long z = x;
      x = y;
      y = z;
    }
    return 16LL * x >= y;
  }
  bool commonEndpoint(segment s) {
    return begin == s.begin || begin == s.end || end == s.begin || end == s.end;
  }
};
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    segment first, second, third;
    first.scan();
    second.scan();
    third.scan();
    if (first.commonEndpoint(third))
      second.swap(third);
    else if (second.commonEndpoint(third))
      first.swap(third);
    else if (!first.commonEndpoint(second)) {
      printf("NO\n");
      continue;
    }
    if (second.hold(third.begin)) first.swap(second);
    if (first.begin == second.begin) {
      first.swapEndpoints();
    } else if (first.begin == second.end) {
      first.swapEndpoints();
      second.swapEndpoints();
    } else if (first.end == second.end) {
      second.swapEndpoints();
    }
    if (VP(first.begin, first.end, second.end) == 0 ||
        SP(first.begin, first.end, second.end) < 0) {
      printf("NO\n");
      continue;
    }
    if (!first.good(third.begin) || !second.good(third.end)) {
      printf("NO\n");
      continue;
    }
    printf("YES\n");
  }
  return 0;
}
