#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

main(){
  int n;
  cin>>n;
  while(n--){
    int xp[3],yp[3],xm[2],ym[2];
    rep(i,3)cin>>xp[i]>>yp[i];

    rep(i,2)cin>>xm[i]>>ym[i];

    bool fe[2];
    fe[0]=fe[1]=true;

    rep(i,3){
      int nx1=xp[(i+1)%3]-xp[i],ny1=yp[(i+1)%3]-yp[i];
      int nx2=xp[(i+2)%3]-xp[i],ny2=yp[(i+2)%3]-yp[i];
      double nx1ab=sqrt(nx1*nx1+ny1*ny1),nx2ab=sqrt(nx2*nx2+ny2*ny2);
      double ang=(1.0*(nx1*nx2+ny1*ny2)/nx1ab/nx2ab);
      //cout<<"ang "<<ang;
      rep(j,2){
	int nxm=xm[j]-xp[i],nym=ym[j]-yp[i];
	double nxmab=sqrt(nxm*nxm+nym*nym);
	double nang=(1.0*(nxm*nx1+nym*ny1)/nxmab/nx1ab);
	//cout<<" "<<nang<<" ";
	if(nang<ang)fe[j]=false;
	nang=(1.0*(nxm*nx2+nym*ny2)/nxmab/nx2ab);
	if(nang<ang)fe[j]=false;
	//cout<<nang<<endl;
      }
    }
    //cout<<fe[0]<<fe[1];
    if(fe[0]==fe[1])cout<<"NG";
    else cout<<"OK";
    cout<<endl;
  }
}
      