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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

typedef struct POINT_tag{
  int x, y;
}POINT_t;

typedef struct LINE_tag{
  POINT_t a, b;
}LINE_t;

typedef struct TRIANGLE_tag{
  POINT_t a, b, c;
}TRIANGLE_t;

int side(POINT_t *p, LINE_t *e){
  POINT_t p1 = *p;
  POINT_t p2 = e->a;
  POINT_t p3 = e->b;

  const int n = p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y);
  if(n > 0) return 1;
  else return -1;
}

int solve(POINT_t *p, TRIANGLE_t *t){
  LINE_t ab, bc, ca;
  ab.a = t->a; ab.b = t->b;
  bc.a = t->b; bc.b = t->c;
  ca.a = t->c; ca.b = t->a;
  const int pab = side(p, &ab);
  const int pbc = side(p, &bc);
  const int pca = side(p, &ca);

  if((0 < pab) && (0 < pbc) && (0 < pca)) return 1;
  if((0 > pab) && (0 > pbc) && (0 > pca)) return 1;
  return 0;
}

int main(){
  int n;
  scanf("%d", &n);
  while(n--){
    TRIANGLE_t t;
    POINT_t k, s;
    scanf("%d%d%d%d%d%d%d%d%d%d", &t.a.x, &t.a.y, &t.b.x, &t.b.y, &t.c.x, &t.c.y, &k.x, &k.y, &s.x, &s.y);
    if(solve(&k, &t) != solve(&s, &t)) puts("OK");
    else puts("NG");
  }
  return 0;
}