#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
double ab,ac,bc;
double ak,bk,ck,as,bs,cs;
bool heron(){
    double sta;
    double wa = 0.0;
    double S,s;
    bool f1=false,f2=false; 
    /*sta*/
    s = (ab+ac+bc)*0.5;
    S = sqrt(s * (s-ab) * (s-ac) * (s-bc));
    sta = S;

    /*wa*/
    s = (ab+ak+bk)*0.5;
    S = sqrt(s*(s-ab)*(s-ak)*(s-bk));
    wa += S;
    s = (ac+ak+ck)*0.5;
    S = sqrt(s*(s-ac)*(s-ak)*(s-ck));
    wa += S;
    s = (bc+bk+ck)*0.5;
    S = sqrt(s*(s-bc)*(s-bk)*(s-ck));
    wa += S;
    if(fabs(sta-wa) <= 0.01)f1 = true;
    wa = 0.0;

    s = (ab+as+bs)*0.5;
    S = sqrt(s*(s-ab)*(s-as)*(s-bs));
    wa += S;
    s = (ac+as+cs)*0.5;
    S = sqrt(s*(s-ac)*(s-as)*(s-cs));
    wa += S;
    s = (bc+bs+cs)*0.5;
    S = sqrt(s*(s-bc)*(s-bs)*(s-cs));
    wa += S;
    if(fabs(sta-wa) <= 0.01)f2 = true;

    if((f1 && f2) || (!f1 && !f2))return false;
    else return true;
}
int main(){
    int hoge;
    scanf("%d",&hoge);
    while( hoge-- ){
        double xa,ya,xb,yb,xc,yc,xk,yk,xs,ys;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xk,&yk,&xs,&ys);
        ab = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
        ac = sqrt((xa-xc)*(xa-xc) + (ya-yc)*(ya-yc));
        bc = sqrt((xb-xc)*(xb-xc) + (yb-yc)*(yb-yc));
        ak = sqrt((xa-xk)*(xa-xk) + (ya-yk)*(ya-yk));
        bk = sqrt((xb-xk)*(xb-xk) + (yb-yk)*(yb-yk));
        ck = sqrt((xc-xk)*(xc-xk) + (yc-yk)*(yc-yk));
        as = sqrt((xa-xs)*(xa-xs) + (ya-ys)*(ya-ys));
        bs = sqrt((xb-xs)*(xb-xs) + (yb-ys)*(yb-ys));
        cs = sqrt((xc-xs)*(xc-xs) + (yc-ys)*(yc-ys));
        bool f = heron();
        (f) ? puts("OK") : puts("NG");
    }
    return 0;
}