#include <iostream>

using namespace std;

class Vector{
public:
	double x,y;

	Vector( double dx, double dy ) : x( dx ), y( dy ) {}
	Vector(){}

	Vector operator-( const Vector& lhs ){
		return Vector( x - lhs.x, y - lhs.y );
	}

	Vector& operator-=( const Vector& lhs ){
		x -= lhs.x;
		y -= lhs.y;
		return *this;
	}
};

double crossProduct( const Vector& rhs, const Vector& lhs ){
	return rhs.x * lhs.y - rhs.y * lhs.x;
}

bool line( Vector a, Vector b, Vector c ){
	b -= a;
	c -= a;

	double answer = crossProduct( b, c );

	if( answer < 0 ) return false;
	else if( answer > 0 ) return true;

	return false;
}

bool inTriangle( const Vector& a, const Vector& b, const Vector& c, const Vector& point ){
	bool answer[3];
	answer[0] = line( a, b, point );
	answer[1] = line( b, c, point );
	answer[2] = line( c, a, point );

	if( answer[0] == answer[1] && answer[1] == answer[2] ) return true;
	

	return false;
}



int main(int argc, char const* argv[])
{
	int n;
	Vector p1,p2,p3,k,s;

	cin >> n;
	for( int i = 0;i < n;i++ ){
		cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> k.x >> k.y >> s.x >> s.y;

		bool answer[2];
		answer[0] = inTriangle( p1, p2, p3, k );
		answer[1] = inTriangle( p1, p2, p3, s );

		if( answer[0] == answer[1] ) cout << "NG" << endl;
		else cout << "OK" << endl;
	}
	return 0;
}