#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> P;

double cross(P a, P b){
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(P a, P b){
  return a.real() * b.real() + a.imag() * b.imag();
}

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > 0) return 1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

int main()
{
  int i;
  int xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
  cin>>i;
  for(;i--;)
    {
      cin>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3>>xk>>yk>>xs>>ys;
      P p1(xp1,yp1),p2(xp2,yp2),p3(xp3,yp3),k(xk,yk),s(xs,ys);

      if((ccw(p1,p2,k)==ccw(p2,p3,k)&& ccw(p2,p3,k)==ccw(p3,p1,k))
	 ^(ccw(p1,p2,s)==ccw(p2,p3,s)&& ccw(p2,p3,s)==ccw(p3,p1,s))
	 )
	cout<<"OK"<<endl;
      else
	cout<<"NG"<<endl;
    }
}