#include <iostream>
#include <vector>
//#include <fstream>	// require freopen
#include <complex>

using namespace std;

typedef complex <double> P;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.altair6vega", "r", stdin );
	int n;
	int i, j;
	vector <bool> res;

	cin >> n;

	for (i = 0; i < n; ++i){
		double x1, y1, x2, y2, x3, y3;
	
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P a(x1, y1), b(x2, y2), c(x3, y3 );

		vector <P> p(2);
		for (j = 0; j < 2; ++j ){
			cin >> p[j].real() >> p[j].imag();
		} // end for

		vector <bool> in (2, false );

		for (j = 0; j < 2; ++j ){	
			if (  ( cross (p[j] - a, p[j] - b ) > 0. && cross (p[j] - b, p[j] - c ) > 0. && cross (p[j] - c , p[j] - a ) > 0. )
			||    ( cross (p[j] - a, p[j] - b ) < 0. && cross (p[j] - b, p[j] - c ) < 0. && cross (p[j] - c , p[j] - a ) < 0. ) ) {
				in[j] = true;
			}else{
				in[j] = false;
			} // end if
		} // end for
		if (in[0] ^ in[1] ){
			res.push_back (true );
		}else{
			res.push_back (false );
		} // end if
	} // end for

	for (i = 0; i < n; ++i){
		if (res[i] ){
			cout << "OK" << endl;
		}else{
			cout << "NG" << endl;
		} // end if
	} // end for
		
	return 0;
}