#include <bits/stdc++.h>
struct P {
  long long x, y;
  P() {}
  P(long long x, long long y) : x(x), y(y) {}
  P operator-(const P &p) const { return P(x - p.x, y - p.y); }
  long long operator^(const P &p) { return x * p.y - y * p.x; }
  long long operator*(const P &p) { return x * p.x + y * p.y; }
  bool operator==(const P &p) { return x == p.x && y == p.y; }
  void in() { scanf("%I64d%I64d", &x, &y); }
};
int T;
P A, B, C, D, E, F, G, AB, AE, EB, CD, CF, FD;
bool f;
inline void swap(P &x, P &y) {
  G = x;
  x = y;
  y = G;
}
int main() {
  scanf("%d", &T);
  do {
    A.in();
    B.in();
    C.in();
    D.in();
    E.in();
    F.in();
    if (A == D)
      swap(C, D);
    else if (A == E)
      swap(C, E), swap(D, F);
    else if (A == F)
      swap(C, F), swap(D, E);
    else if (B == C)
      swap(A, B);
    else if (B == D)
      swap(A, B), swap(C, D);
    else if (B == E)
      swap(A, B), swap(C, E), swap(D, F);
    else if (B == F)
      swap(A, B), swap(C, F), swap(D, E);
    else if (C == E)
      swap(A, E), swap(B, F);
    else if (C == F)
      swap(A, F), swap(B, E);
    else if (D == E)
      swap(C, D), swap(A, E), swap(B, F);
    else if (D == F)
      swap(C, D), swap(A, F), swap(B, E);
    if ((E - A) ^ (E - B)) swap(E, F);
    AB = B - A;
    AE = E - A;
    EB = B - E;
    CD = D - C;
    CF = F - C;
    FD = D - F;
    f = (A == C);
    f &= ((AE ^ EB) == 0);
    f &= ((CF ^ FD) == 0);
    f &= ((AB ^ CD) && (AB * CD) >= 0);
    f &= ((AE * EB) * 25 >= (AB * AB) * 4);
    f &= ((CF * FD) * 25 >= (CD * CD) * 4);
    puts(f ? "YES" : "NO");
  } while (--T);
  return 0;
}
