#include using namespace std; using int64 = long long; const int64 INF = 1LL << 62; int main() { int N; cin >> N; while(N--) { double x[3], y[3]; cin >> x[0] >> x[1] >> x[2]; cin >> y[0] >> y[1] >> y[2]; if(x[0] != x[2] || y[0] != y[2]) { bool flag = false; flag |= y[2] < y[1] && y[0] < y[1] && x[1] <= x[2] && x[0] * (y[1] - y[2]) <= x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] < y[1] && y[0] < y[1] && x[1] <= x[2] && x[0] * (y[1] - y[2]) > x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] < y[1] && y[0] < y[1] && x[1] > x[2] && x[0] >= x[1]; flag |= y[2] < y[1] && y[0] == y[1] && x[1] <= x[2] && x[0] < x[1]; flag |= y[2] < y[1] && y[0] == y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[2] < y[1] && y[0] > y[1] && x[1] <= x[2] && x[0] * (y[1] - y[2]) < x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] < y[1] && y[0] > y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[1] == y[2] && y[0] < y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[1] == y[2] && y[0] < y[1] && x[1] > x[2] && x[0] >= x[1]; flag |= y[1] == y[2] && y[0] == y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[1] == y[2] && y[0] > y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[2] > y[1] && y[0] < y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[2] > y[1] && y[0] < y[1] && x[1] > x[2] && x[1] <= x[0] && x[0] * (y[2] - y[1]) < -x[1] * y[0] + x[2] * y[0] - x[2] * y[1] + x[1] * y[2]; flag |= y[2] > y[1] && y[0] == y[1] && x[1] > x[2] && x[0] < x[1]; flag |= y[2] > y[1] && y[0] > y[1] && x[1] > x[2] && x[0] * (y[1] - y[2]) <= x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] > y[1] && y[0] > y[1] && x[1] > x[2] && -x[1] * y[0] + x[2] * y[0] - x[2] * y[1] + x[1] * y[2] < x[0] * (y[2] - y[1]) && x[0] < x[1]; if(flag) { puts("YES"); continue; } flag |= y[2] < y[1] && y[0] < y[1] && x[1] < x[2] && x[1] < x[0] && x[0] * (y[2] - y[1]) < -x[1] * y[0] + x[2] * y[0] - x[2] * y[1] + x[1] * y[2]; flag |= y[2] < y[1] && y[0] < y[1] && x[1] < x[2] && x[0] * (y[1] - y[2]) >= x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] < y[1] && y[0] == y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[2] < y[1] && x[1] < x[2] && -x[1] * y[0] + x[2] * y[0] - x[2] * y[1] + x[1] * y[2] < x[0] * (y[2] - y[1]) && x[0] <= x[1]; flag |= y[2] < y[1] && y[0] > y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[1] == y[2] && y[0] < y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[1] == y[2] && y[0] == y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[1] == y[2] && y[0] > y[1] && x[1] < x[2] && x[0] <= x[1]; flag |= y[1] == y[2] && y[0] > y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[2] > y[1] && y[0] < y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[2] > y[1] && y[0] < y[1] && x[1] >= x[2] && x[0] * (y[1] - y[2]) > x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] > y[1] && y[0] == y[1] && x[1] < x[2] && x[0] > x[1]; flag |= y[2] > y[1] && y[0] == y[1] && x[1] >= x[2] && x[0] > x[1]; flag |= y[2] > y[1] && y[0] > y[1] && x[1] < x[2] && x[0] <= x[1]; flag |= y[2] > y[1] && y[0] > y[1] && x[1] >= x[2] && x[0] * (y[1] - y[2]) < x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); flag |= y[2] > y[1] && y[0] > y[1] && x[1] >= x[2] && x[0] * (y[1] - y[2]) >= x[2] * (y[1] - y[0]) + x[1] * (y[0] - y[2]); if(flag) { puts("YES"); continue; } } puts("NO"); } }