#include<iostream>
#include<cmath>
using namespace std;
bool eq(double x,double y){
  double z=x-y;
  if(z<0.000000001)return true;
  else return false;
}
double S3( double x1, double y1, double x2,double y2, double x3, double y3 ){

  double sum = 0;
  sum = ( x1*y2 - x2*y1 ) + ( x2*y3 - x3*y2 ) + ( x3*y1 - x1*y3 );
  sum = abs(sum);
  sum /= 2;

  return sum;
}
int n;
double xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;

int check(double x,double y){
  double a = S3(xp1,yp1,xp2,yp2,x,y);
  double b = S3(xp2,yp2,xp3,yp3,x,y);
  double c = S3(xp3,yp3,xp1,yp1,x,y);
  double d = S3(xp1,yp1,xp2,yp2,xp3,yp3);
  if(eq(a+b+c,d)){
    return 1;
  }else{
    return -1;
  }
}

int main(){
  cin>>n;
  while(n--){
    cin>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3>>xk>>yk>>xs>>ys;
    if(check(xk,yk)==check(xs,ys))cout<<"NG"<<endl;
    else cout<<"OK"<<endl;
  }
  return 0;
}