#include <cstdio>

bool line(int x1, int y1, int x2, int y2, int x, int y){
	return (x2 - x1) * (y - y1) > (y2 - y1) * (x - x1);
}

bool triangle(int x1, int y1, int x2, int y2, int x3, int y3, int x, int y){
	return	line(x1, y1, x2, y2, x, y) == line(x1, y1, x2, y2, x3, y3) &&
			line(x2, y2, x3, y3, x, y) == line(x2, y2, x3, y3, x1, y1) &&
			line(x3, y3, x1, y1, x, y) == line(x3, y3, x1, y1, x2, y2);
}

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		int x1, y1, x2, y2, x3, y3, ax, ay, bx, by;
		scanf("%d%d%d%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &ax, &ay, &bx, &by);
		if(triangle(x1, y1, x2, y2, x3, y3, ax, ay) != triangle(x1, y1, x2, y2, x3, y3, bx, by)){
			printf("OK\n");
		}
		else{
			printf("NG\n");
		}
	}
	return 0;
}