#include <iostream>
using namespace std;

int cross(int a, int b, int c, int d) {
    return a * d - b * c;
}

int main() {
    int n;

    cin >> n;
    while (n--) {
        int xp[3], yp[3], x[2], y[2];
        int cp[2][3];

        for (int i = 0; i < 3; i++) {
            cin >> xp[i] >> yp[i];
        }   
        for (int i = 0; i < 2; i++) {
            cin >> x[i] >> y[i];
        }

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                int k = (j+1) % 3;
                cp[i][j] = cross(xp[k]-xp[j], yp[k]-yp[j], x[i]-xp[j], y[i]-yp[j]) > 0;
            }
        }
        bool judge = false;
        if (cp[0][0] == cp[0][1] && cp[0][0] == cp[0][2]) {
            if (cp[1][0] != cp[1][1] || cp[1][0] != cp[1][2]) {
                judge = true;
            }
        }
        else if (cp[1][0] == cp[1][1] && cp[1][0] == cp[1][2]) {
            judge = true;
        }
        cout << (judge? "OK": "NG") << endl;

    }
    return 0;
}