#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <typename T>
struct Point {
  T x, y;
  Point(T _x = 0, T _y = 0) : x(_x), y(_y) {}
  void read();
  void swap() { swap(x, y); }
  double len() const;
  Point<double> asDouble() { return Point<double>(x, y); }
  Point<T> norm() const;
  Point<T> ort() const { return Point<T>(y, -x); }
};
template <>
void Point<int>::read() {
  scanf("%d%d", &x, &y);
}
template <>
void Point<long long>::read() {
  scanf("%lld%lld", &x, &y);
}
template <>
void Point<double>::read() {
  scanf("%lf%lf", &x, &y);
}
template <typename T>
Point<T> operator-(const Point<T> &a) {
  return Point<T>(-a.x, -a.y);
}
template <typename T>
Point<T> operator+(const Point<T> &a, const Point<T> &b) {
  return Point<T>(a.x + b.x, a.y + b.y);
}
template <typename T>
Point<T> operator-(const Point<T> &a, const Point<T> &b) {
  return Point<T>(a.x - b.x, a.y - b.y);
}
template <typename T>
Point<T> operator*(const T a, const Point<T> &b) {
  return Point<T>(a * b.x, a * b.y);
}
template <typename T>
Point<T> operator*(const Point<T> &b, const T a) {
  return Point<T>(a * b.x, a * b.y);
}
template <typename T>
Point<T> operator/(const Point<T> &b, const T a) {
  return Point<T>(b.x / a, b.y / a);
}
template <typename T>
long long operator*(const Point<T> &a, const Point<T> &b) {
  return a.x * (long long)b.x + a.y * (long long)b.y;
}
template <typename T>
long long operator^(const Point<T> &a, const Point<T> &b) {
  return a.x * (long long)b.y - a.y * (long long)b.x;
}
template <typename T>
double Point<T>::len() const {
  return sqrt((double)((*this) * (*this)));
}
template <typename T>
Point<T> Point<T>::norm() const {
  return (*this) / len();
}
template <typename T>
bool operator<(const Point<T> &a, const Point<T> &b) {
  return a.x < b.x || a.x == b.x && a.y < b.y;
}
bool operator==(const Point<long long> &a, const Point<long long> &b) {
  return a.x == b.x && a.y == b.y;
}
int sign(int x) {
  if (x == 0) return 0;
  if (x > 0)
    return +1;
  else
    return -1;
}
int sign(double x) {
  if (fabs(x) < 1.0e-11) return 0;
  if (x > 0)
    return +1;
  else
    return -1;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
const Point<double> INFDPnt(1.0e30, 1.0e30);
Point<long long> a[3][2];
bool inside(Point<long long> a, Point<long long> b, Point<long long> p) {
  if (((b - a) ^ (p - a)) != 0) return false;
  if (((b - a) * (p - a)) <= 0 || ((a - b) * (p - b)) <= 0) return false;
  long long t = (b - a) * (b - a);
  long long t1 = (p - a) * (p - a);
  long long t2 = (p - b) * (p - b);
  return 25 * t1 >= t && 25 * t2 >= t;
}
bool solve() {
  int ii1 = -1, jj1 = -1, ii2 = -1, jj2 = -1;
  for (int i1 = 0, _n = (3); i1 < _n; i1++)
    for (int j1 = 0, _n = (2); j1 < _n; j1++)
      for (int i2 = 0, _n = (i1); i2 < _n; i2++)
        for (int j2 = 0, _n = (2); j2 < _n; j2++)
          if (a[i1][j1] == a[i2][j2]) {
            if (ii1 != -1) return false;
            ii1 = i1;
            jj1 = j1;
            ii2 = i2;
            jj2 = j2;
          }
  if (ii1 == -1) return false;
  if (ii1 == ii2) return false;
  if (jj1 == 1) swap(a[ii1][0], a[ii1][1]);
  if (jj2 == 1) swap(a[ii2][0], a[ii2][1]);
  int end = 0 + 1 + 2 - ii1 - ii2;
  if (end != 2)
    for (int j = 0, _n = (2); j < _n; j++) swap(a[end][j], a[2][j]);
  Point<long long> p = a[0][0];
  if (((a[0][1] - p) ^ (a[1][1] - p)) == 0) return false;
  if (((a[0][1] - p) * (a[1][1] - p)) < 0) return false;
  return inside(a[0][0], a[0][1], a[2][0]) &&
             inside(a[1][0], a[1][1], a[2][1]) ||
         inside(a[0][0], a[0][1], a[2][1]) && inside(a[1][0], a[1][1], a[2][0]);
}
int main() {
  int tests;
  scanf("%d", &tests);
  for (int test = 1; test <= tests; test++) {
    for (int i = 0, _n = (3); i < _n; i++)
      for (int j = 0, _n = (2); j < _n; j++) a[i][j].read();
    printf("%s\n", solve() ? "YES" : "NO");
  }
  return 0;
}
