#include <bits/stdc++.h>
using namespace std;
struct Point {
  Point() : x(0), y(0) {}
  Point(int x_, int y_) : x(x_), y(y_) {}
  Point(const Point& b) : x(b.x), y(b.y) {}
  bool operator==(const Point& b) const { return (x == b.x && y == b.y); }
  bool operator<(const Point& b) const {
    if (x < b.x)
      return true;
    else if (x > b.x)
      return false;
    else
      return y < b.y;
  }
  int x;
  int y;
};
struct Segment {
  Segment() : p1(), p2() {}
  Segment(const Point& p1_, const Point& p2_) : p1(p1_), p2(p2_) {}
  Point p1;
  Point p2;
};
bool checkAngle(int64_t x1, int64_t y1, int64_t x2, int64_t y2) {
  if (x1 * y2 == x2 * y1) return false;
  if (x1 * x1 + y1 * y1 + x2 * x2 + y2 * y2 <
      (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) {
    return false;
  }
  return true;
}
bool onSegment(const Point& p1, const Point& p2, const Point& p3) {
  int64_t x1, y1, x2, y2, x3, y3;
  x1 = p1.x;
  y1 = p1.y;
  x2 = p2.x;
  y2 = p2.y;
  x3 = p3.x;
  y3 = p3.y;
  return (x3 - x1) * (y2 - y1) == (x2 - x1) * (y3 - y1);
}
bool checkRatio(const Point& p1, const Point& p2, const Point& p3) {
  if (!onSegment(p1, p2, p3)) return false;
  int64_t x1, y1, x2, y2, x3, y3;
  x1 = p1.x;
  y1 = p1.y;
  x2 = p2.x;
  y2 = p2.y;
  x3 = p3.x;
  y3 = p3.y;
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  if (x3 > x2 || x3 < x1 || y3 > y2 || y3 < y1) return false;
  int64_t d1, d2;
  if (x1 != x2) {
    d1 = x3 - x1;
    d2 = x2 - x3;
  } else {
    d1 = y3 - y1;
    d2 = y2 - y3;
  }
  if (d1 > d2) swap(d1, d2);
  if (4 * d1 < d2) return false;
  return true;
}
void process() {
  Point points[6];
  int x, y;
  for (int i = 0; i < 6; i++) {
    cin >> x >> y;
    points[i] = Point(x, y);
  }
  if (points[0] == points[1] || points[2] == points[3] ||
      points[4] == points[5]) {
    cout << "NO" << endl;
    return;
  }
  Segment segments[3];
  map<Point, int> pointMap;
  int index1 = -1;
  int index2 = -1;
  for (int i = 0; i < 6; i++) {
    if (pointMap.find(points[i]) == pointMap.end()) {
      pointMap.insert(pair<Point, int>(points[i], i));
    } else {
      index1 = i;
      index2 = pointMap[points[i]];
    }
  }
  if (index1 == -1) {
    cout << "NO" << endl;
    return;
  }
  set<int> blocks;
  blocks.insert(0);
  blocks.insert(1);
  blocks.insert(2);
  blocks.erase(index1 / 2);
  blocks.erase(index2 / 2);
  segments[0].p1 = points[index2];
  segments[0].p2 = points[index2 / 2 * 4 - index2 + 1];
  segments[1].p1 = points[index1];
  segments[1].p2 = points[index1 / 2 * 4 - index1 + 1];
  int block3 = *(blocks.begin());
  segments[2].p1 = points[block3 * 2];
  segments[2].p2 = points[block3 * 2 + 1];
  if (checkAngle(segments[0].p2.x - segments[0].p1.x,
                 segments[0].p2.y - segments[0].p1.y,
                 segments[1].p2.x - segments[1].p1.x,
                 segments[1].p2.y - segments[1].p1.y) == false) {
    cout << "NO" << endl;
    return;
  }
  if (onSegment(segments[0].p1, segments[0].p2, segments[2].p1)) {
    if (!checkRatio(segments[0].p1, segments[0].p2, segments[2].p1) ||
        !checkRatio(segments[1].p1, segments[1].p2, segments[2].p2)) {
      cout << "NO" << endl;
      return;
    }
  } else {
    if (!checkRatio(segments[0].p1, segments[0].p2, segments[2].p2) ||
        !checkRatio(segments[1].p1, segments[1].p2, segments[2].p1)) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    process();
  }
  return 0;
}
