#include <iostream>
#include <math.h>

using namespace std;

double square_calc(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double square = 0;
	double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	double b = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
	double c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
	double s = (a + b + c) / 2;
	return(sqrt(s * (s - a ) * (s - b) * (s - c)));
}

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
		cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
		double square = square_calc(xp1, yp1, xp2, yp2, xp3, yp3);
		double square1 = square_calc(xk, yk, xp1, yp1, xp2, yp2) + square_calc(xk, yk, xp1, yp1, xp3, yp3) + square_calc(xk, yk, xp2, yp2, xp3, yp3);
		double square2 = square_calc(xs, ys, xp1, yp1, xp2, yp2) + square_calc(xs, ys, xp1, yp1, xp3, yp3) + square_calc(xs, ys, xp2, yp2, xp3, yp3);
		if(fabs(square - square1) <= 1e-6 && fabs(square - square2) >= 1e-6 ||
		   fabs(square - square1) >= 1e-6 && fabs(square - square2) <= 1e-6)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}