#include <bits/stdc++.h>
using namespace std;
template <typename type>
type gcd(type a, type b) {
  return b ? gcd(b, a % b) : a;
}
bool check(pair<complex<long long>, complex<long long>> line,
           complex<long long> point) {
  if (point.real() < min(line.first.real(), line.second.real()) ||
      point.imag() < min(line.first.imag(), line.second.imag()) ||
      point.real() > max(line.first.real(), line.second.real()) ||
      point.imag() > max(line.first.imag(), line.second.imag()))
    return true;
  if (line.first.real() == line.second.real())
    return point.real() != line.first.real();
  if (line.first.imag() == line.second.imag())
    return point.imag() != line.first.imag();
  long long num = line.first.imag() - line.second.imag(),
            den = line.first.real() - line.second.real(), gcdnd = gcd(num, den);
  num /= gcdnd, den /= gcdnd;
  if ((point.real() - line.first.real()) % den) return true;
  return line.first.imag() + num * (point.real() - line.first.real()) / den !=
         point.imag();
}
int main(int argc, char *argv[], char *envp[]) {
  array<pair<complex<long long>, complex<long long>>, 3> lines;
  complex<long long> intersection, ufind(2147483647, 2147483647);
  int cnt, line_1, line_2, line_3;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> cnt;
  int xpos1, xpos2, ypos1, ypos2;
  while (cnt--) {
    for (int i = 0; i < 3; i++)
      cin >> xpos1 >> ypos1 >> xpos2 >> ypos2, lines[i].first = {xpos1, ypos1},
                                               lines[i].second = {xpos2, ypos2};
    intersection = ufind;
    for (int i = 0; i < 2; i++)
      for (int j = i + 1; j < 3; j++)
        if (lines[i].first == lines[j].first)
          if (lines[i].second == lines[j].second) {
            cout << "NO";
            goto nextcase;
          } else if (intersection != ufind) {
            cout << "NO";
            goto nextcase;
          } else
            line_1 = i, line_2 = j, line_3 = 3 - i - j,
            intersection = lines[i].first;
        else if (lines[i].first == lines[j].second)
          if (lines[i].second == lines[j].first) {
            cout << "NO";
            goto nextcase;
          } else if (intersection != ufind) {
            cout << "NO";
            goto nextcase;
          } else
            line_1 = i, line_2 = j, line_3 = 3 - i - j,
            intersection = lines[i].first;
        else if (lines[i].second == lines[j].second)
          if (lines[i].first == lines[j].first) {
            cout << "NO";
            goto nextcase;
          } else if (intersection != ufind) {
            cout << "NO";
            goto nextcase;
          } else
            line_1 = i, line_2 = j, line_3 = 3 - i - j,
            intersection = lines[i].second;
        else if (lines[i].second == lines[j].first)
          if (lines[i].first == lines[j].second) {
            cout << "NO";
            goto nextcase;
          } else if (intersection != ufind) {
            cout << "NO";
            goto nextcase;
          } else
            line_1 = i, line_2 = j, line_3 = 3 - i - j,
            intersection = lines[i].second;
    if (intersection == ufind) {
      cout << "NO";
      goto nextcase;
    }
    if (check(lines[line_1], lines[line_3].first))
      swap(lines[line_3].first, lines[line_3].second);
    if (check(lines[line_1], lines[line_3].first) ||
        check(lines[line_2], lines[line_3].second)) {
      cout << "NO";
      goto nextcase;
    }
    if (norm(lines[line_1].first - lines[line_3].first) /
                (long double)norm(lines[line_1].second - lines[line_3].first) >
            16 ||
        norm(lines[line_1].first - lines[line_3].first) /
                (long double)norm(lines[line_1].second - lines[line_3].first) <
            0.0625 ||
        norm(lines[line_2].first - lines[line_3].second) /
                (long double)norm(lines[line_2].second - lines[line_3].second) >
            16 ||
        norm(lines[line_2].first - lines[line_3].second) /
                (long double)norm(lines[line_2].second - lines[line_3].second) <
            0.0625) {
      cout << "NO";
      goto nextcase;
    }
    if (norm(intersection - lines[line_3].first) +
            norm(intersection - lines[line_3].second) <
        norm(lines[line_3].first - lines[line_3].second)) {
      cout << "NO";
      goto nextcase;
    }
    cout << "YES";
  nextcase:
    cout << '\n';
  }
  return 0;
}
