#include<iostream>
#include<cmath>
using namespace std;

int x,y,x2,y2,x3,y3,xk,yk,xs,ys;

double len(int xa, int ya,int xb,int yb){
  return sqrt( (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb) );
}

double flon(int xa,int ya, int xb, int yb ,int xc ,int yc){
  double l1,l2,l3,s;
  l1 = len(xa,ya,xb,yb);
  l2 = len(xb,yb,xc,yc);
  l3 = len(xc,yc,xa,ya);
  s = (l1+l2+l3)/2;

  return sqrt( s*(s-l1)*(s-l2)*(s-l3) );
}

bool interk(void){
  if( fabs(flon(x,y,x2,y2,xk,yk) + flon(x,y,x3,y3,xk,yk) + flon(x2,y2,x3,y3,xk,yk) - flon(x,y,x2,y2,x3,y3) ) < 1e-10 )return true;
  else return false;
}

bool inters(void){
  if( fabs(flon(x,y,x2,y2,xs,ys) + flon(x,y,x3,y3,xs,ys) + flon(x2,y2,x3,y3,xs,ys) - flon(x,y,x2,y2,x3,y3) ) < 1e-10 )return true;
  else return false;
}

int main(){
  int n;

  cin >> n;
  while(n){
    n--;
    cin >> x >> y >> x2 >> y2 >> x3 >> y3 >> xk >> yk >> xs >> ys;

    if( !interk() && inters() )cout << "OK" << endl;
    else cout << "NG" << endl;
  }
}