#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-3;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int main(void){
  int n;
  cin>>n;
  while(n--){
    vector<P> point(5);
    REP(i,5){
      double x,y;
      cin>>x>>y;
      point[i] = P(x,y);
    }
    double S = abs(cross(point[2]-point[0],point[1]-point[0]));
    double par = 0;
    bool in1,in2;
    REP(i,3){
      par += abs(cross(point[i]-point[3],point[(i+1)%3]-point[3]));
    }
    in1 = (abs(S-par)<EPS);
    par = 0;
    REP(i,3){
      par += abs(cross(point[i]-point[4],point[(i+1)%3]-point[4]));
    }
    in2 = (abs(S-par)<EPS);
    if((in1&&in2)||!(in1||in2)){
      cout<<"NG"<<endl;
    }else{
      cout<<"OK"<<endl;
    }
  }



  return 0;
}