#include <iostream>
using namespace std;

double x[5], y[5];

bool check() {
  double xa[3], ya[3], s[3];
  bool in[2], b[3];
  for (int i=0; i<3; i++) {
    xa[i] = y[(i+1)%3] - y[i];
    ya[i] = -x[(i+1)%3] + x[i];
    s[i] = xa[i]*x[i] + ya[i]*y[i];
  }
  for (int i=0; i<2; i++) {
    for (int j=0; j<3; j++) {
      b[j] = (xa[j]*x[i+3] + ya[j]*y[i+3] < s[j]);
    }
    in[i] = (b[0] == b[1] && b[1] == b[2]);
  }
  return (in[0] != in[1]);
}

int main() {
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    for (int j=0; j<5; j++) {
      cin >> x[j] >> y[j];
    }
    if (check()) {
      cout << "OK" << endl;
    } else {
      cout << "NG" << endl;
    }
  }
}