#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>

#define SAME_SIGN( a , b ) ( a * b > 0 ? true : false )

namespace geometry{

#define EPS 1E-10

	struct point{
		double x;
		double y;
		point(){}
		point( double x , double y ):x(x),y(y){}
		point& operator += ( const point& p ){ x += p.x; y += p.y; return *this; }
		point& operator -= ( const point& p ){ x -= p.x; y -= p.y; return *this; }
		point& operator *= ( double factor ){ x *= factor; y *= factor; return *this; }
		point& operator /= ( double factor ){ x /= factor; y /= factor; return *this; }
		bool operator == ( const point& p ) const { return (std::abs(x - p.x) < EPS && std::abs(y - p.y) < EPS); }
		bool operator != ( const point& p ) const { return !(*this == p); }
		double norm() const{ return sqrt( pow( x , 2) + pow( y , 2 ) ); }
	};

	typedef point vector2d;

	struct triangle{
		point a;
		point b;
		point c;
		triangle(){}
		triangle( point a , point b , point c ):a(a),b(b),c(c){}
	};

	point operator + ( const point& p1 , const point& p2 ){
		point p(p1);
		p += p2;
		return p;
	}
	point operator - ( const point& p1 , const point& p2 ){
		point p(p1);
		p -= p2;
		return p;
	}
	point operator * ( const point& p1 , double factor ){
		point p(p1);
		p *= factor;
		return p;
	}
	point operator * ( double factor , const point& p1 ){
		point p(p1);
		p *= factor;
		return p;
	}
	point operator / ( const point& p1 , double factor ){
		point p(p1);
		p /= factor;
		return p;
	}
	std::istream& operator >> ( std::istream& s , point& p ){
		return s >> p.x >> p.y;
	}

	double get_distance( const point& p1 , const point& p2 ){
		return sqrt( pow( p1.x - p2.x , 2 ) + pow( p1.y - p2.y , 2 ) );
	}

	double get_cross_product( const point& a , const point& b , const point& o ){
		vector2d oa = a - o;
		vector2d ob = b - o;
		return oa.x * ob.y - ob.x * oa.y;
	}
}

using namespace geometry;
using namespace std;

typedef triangle wall;
class field;

class player{
public:
	explicit player( const field& field );
	bool is_inside( const wall& wall ) const;
	bool can_see( const player& target ) const;
	void move( const point& new_location );
	const point& get_location() const;
private:
	const field& m_field;
	point m_loc;
};

class field{
public:
	void place( const wall& w );
	wall get_wall() const;
private:
	wall m_wall;
};

player::player( const field& field ):m_field(field){}

bool player::is_inside( const wall& wall ) const{
	if(
	SAME_SIGN( get_cross_product( wall.a , wall.b , m_loc ) , get_cross_product( wall.b , wall.c , m_loc ) ) &&
	SAME_SIGN( get_cross_product( wall.b , wall.c , m_loc ) , get_cross_product( wall.c , wall.a , m_loc ) )
	){
		return true;
	}
	else{
		return false;
	}
}

bool player::can_see( const player& target ) const{
	if( this->is_inside( m_field.get_wall() ) && target.is_inside( m_field.get_wall() ) ){
		return true;
	}
	else if( this->is_inside( m_field.get_wall() ) != target.is_inside( m_field.get_wall() ) ){
		return false;
	}
	else{
		return true;
	}
}

void player::move( const point& new_location ){
	m_loc = new_location;
}

const point& player::get_location() const{
	return m_loc;
}

void field::place( const wall& wall ){
	m_wall = wall;
}

wall field::get_wall() const{
	return m_wall;
}

int main(void)
{
	int n;

	cin >> n;

	for( int i = 0 ; i < n ; i++ ){
		field f;
		player ori(f);
		player hiko(f);

		point p1, p2, p3, pk, ps;

		cin >> p1 >> p2 >> p3 >> pk >> ps;

		hiko.move(pk);
		ori.move(ps);
		wall w( p1 , p2 , p3 );
		f.place(w);

		cout << (hiko.can_see(ori) ? "NG":"OK") << endl;
	}

	return 0;
}

Measured memory_bytes: 1224