#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
bool in_tri(const P& p, const VP& tri){
    return dot(tri[1]-tri[0], p-tri[0])>0 &&
        dot(tri[2]-tri[1], p-tri[1])>0 &&
        dot(tri[0]-tri[2], p-tri[2])>0;
}

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        VP tri(3);
        for(int j=0; j<3; j++){
            int x,y;
            cin >> x >> y;
            tri[j] = P(x,y);
        }
        VP sg(2);
        for(int j=0; j<2; j++){
            int x,y;
            cin >> x >> y;
            sg[j] = P(x,y);
        }
        if(in_tri(sg[0], tri) != in_tri(sg[1], tri)){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
    return 0;
}

