#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef complex<int> Point;

int cross(Point a,Point b)
{
	return imag(conj(a)*b);
}

bool in(Point p,Point t[])
{
	int c[3];
	rep(i,3)
		c[i]=cross(t[(i+1)%3]-t[i],p-t[i]);
	return count_if(c,c+3,bind2nd(less<int>(),0))%3==0;
}

int main()
{
	int n;
	cin>>n;
	rep(tc,n){
		Point t[3],m,w;
		rep(i,3)
			cin>>real(t[i])>>imag(t[i]);
		cin>>real(m)>>imag(m)>>real(w)>>imag(w);
		bool inm=in(m,t);
		bool inw=in(w,t);
		puts(inm!=inw?"OK":"NG");
	}
	
	return 0;
}