def z a,b,c,d;a*d-b*c>0;end
gets.to_i.times{a,b,c,d,e,f,g,h,i,j=gets.split.map &:to_i
puts (z(a-c,b-d,a-g,b-h)==(k=z c-e,d-f,c-g,d-h)&&k==z(e-a,f-b,e-g,f-h))^(z(a-c,b-d,a-i,b-j)==(l=z c-e,d-f,c-i,d-j)&&l==z(e-a,f-b,e-i,f-j))?:OK:"NG"}