#include <bits/stdc++.h>
using namespace std;
bool zero(long long a, long long b, long long c, long long x, long long y) {
  if (a * 1ll * x + b * 1ll * y + c == 0) return true;
  return false;
}
bool dothis(long long x1, long long y1, long long x2, long long y2,
            long long x3, long long y3, long long x4, long long y4,
            long long x5, long long y5, long long x6, long long y6) {
  bool f = false;
  if (((x1 == x3) && (y1 == y3)) || ((x1 == x4) && (y1 == y4)) ||
      ((x2 == x3) && (y2 == y3)) || ((x2 == x4) && (y2 == y4)))
    f = true;
  if (!f) return f;
  long long x, xx, y, yy;
  if ((x1 == x3) && (y1 == y3)) {
    x = x2 - x1;
    y = y2 - y1;
    xx = x4 - x3;
    yy = y4 - y3;
  } else if ((x1 == x4) && (y1 == y4)) {
    x = x2 - x1;
    y = y2 - y1;
    xx = -x4 + x3;
    yy = -y4 + y3;
  } else if ((x2 == x3) && (y2 == y3)) {
    x = -x2 + x1;
    y = -y2 + y1;
    xx = x4 - x3;
    yy = y4 - y3;
  } else {
    x = -x2 + x1;
    y = -y2 + y1;
    xx = -x4 + x3;
    yy = -y4 + y3;
  }
  if ((x * 1ll * xx + y * 1ll * yy) < 0) return false;
  if ((x * 1ll * yy - y * 1ll * xx) == 0) return false;
  if ((x2 - x1) * 1ll * (y6 - y5) - (y2 - y1) * 1ll * (x6 - x5) == 0)
    return false;
  if ((x4 - x3) * 1ll * (y6 - y5) - (y4 - y3) * 1ll * (x6 - x5) == 0)
    return false;
  long long A1 = y2 - y1;
  long long B1 = x1 - x2;
  long long C1 = y1 * 1ll * (x2 - x1) - x1 * 1ll * (y2 - y1);
  long long A2 = y4 - y3;
  long long B2 = x3 - x4;
  long long C2 = y3 * 1ll * (x4 - x3) - x3 * 1ll * (y4 - y3);
  f = false;
  if ((zero(A1, B1, C1, x5, y5) && zero(A2, B2, C2, x6, y6)) ||
      (zero(A1, B1, C1, x6, y6) && zero(A2, B2, C2, x5, y5)))
    f = true;
  if (!f) return f;
  if (zero(A1, B1, C1, x5, y5)) {
    f = false;
    if ((x5 >= ((x1 < x2) ? (x1) : (x2))) &&
        (x5 <= ((x1 < x2) ? (x2) : (x1))) &&
        (x6 <= ((x3 < x4) ? (x4) : (x3))) && (x6 >= ((x3 < x4) ? (x3) : (x4))))
      f = true;
    if (!f) return f;
    x = x5;
    y = y5;
    xx = x6;
    yy = y6;
  } else {
    f = false;
    if ((x6 >= ((x1 < x2) ? (x1) : (x2))) &&
        (x6 <= ((x1 < x2) ? (x2) : (x1))) &&
        (x5 <= ((x3 < x4) ? (x4) : (x3))) && (x5 >= ((x3 < x4) ? (x3) : (x4))))
      f = true;
    if (!f) return f;
    xx = x5;
    yy = y5;
    x = x6;
    y = y6;
  }
  long long l1 = (x - x1) * 1ll * (x - x1) + (y - y1) * 1ll * (y - y1);
  long long l2 = (x - x2) * 1ll * (x - x2) + (y - y2) * 1ll * (y - y2);
  if (l1 < l2) swap(l1, l2);
  if (l2 == 0) return false;
  if (l1 > 16 * 1ll * l2) return false;
  l1 = (xx - x3) * 1ll * (xx - x3) + (yy - y3) * 1ll * (yy - y3);
  l2 = (xx - x4) * 1ll * (xx - x4) + (yy - y4) * 1ll * (yy - y4);
  if (l1 < l2) swap(l1, l2);
  if (l2 == 0) return false;
  if (l1 > 16 * 1ll * l2) return false;
  return true;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
    scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4,
          &x5, &y5, &x6, &y6);
    if ((dothis((long long)x1, (long long)y1, (long long)x2, (long long)y2,
                (long long)x3, (long long)y3, (long long)x4, (long long)y4,
                (long long)x5, (long long)y5, (long long)x6, (long long)y6)) ||
        (dothis((long long)x1, (long long)y1, (long long)x2, (long long)y2,
                (long long)x5, (long long)y5, (long long)x6, (long long)y6,
                (long long)x3, (long long)y3, (long long)x4, (long long)y4)) ||
        (dothis((long long)x5, (long long)y5, (long long)x6, (long long)y6,
                (long long)x3, (long long)y3, (long long)x4, (long long)y4,
                (long long)x1, (long long)y1, (long long)x2, (long long)y2)))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
