class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x=x
    @y=y
  end
end

# 1次関数(2点標準形)
def linear(p1, p2)
  lambda { |p| (p2.y-p1.y)*(p.x-p1.x)-(p2.x-p1.x)*(p.y-p1.y) }
end

# 包含判定
def inner?(p, poly)

  temp=poly+[poly[0]]

  a=linear(temp[0], temp[1]).call(p)
  1.upto(temp.size-2) do |i|
    b=a
    a=linear(temp[i], temp[i+1]).call(p)
    if ((a<0&&b<0)|| (a>0&&b>0))
      next
    else
      return false
    end
  end
  true
end

gets.to_i.times do

  ps = gets.split.map(&:to_f)

  p1=Point.new(ps[0], ps[1])
  p2=Point.new(ps[2], ps[3])
  p3=Point.new(ps[4], ps[5])
  poly=[p1, p2, p3]

  pa=Point.new(ps[6], ps[7]) # altair
  pv=Point.new(ps[8], ps[9]) # vega

  if inner?(pv, poly)
    unless inner?(pa, poly)
      puts :OK
      next
    end
  else
    if inner?(pa, poly)
      puts :OK
      next
    end
  end

  puts :NG

end