def projecter(x, y, xp, yp)
  return (xp * x + yp * y) / (x ** 2 + y ** 2), (yp * x - xp * y) / (x ** 2 + y ** 2)
end
def main(input = STDIN)
  input.gets.to_i.times do
    points = input.gets.split(" ").map(&:to_r)
    a1, b1, a2, b2 = *projecter(points[2] - points[0], points[3] - points[1], points[4], points[5]), *projecter(points[2] - points[0], points[3] - points[1], points[6], points[7])
    if ((b1 - b2) + (a1 * b2 - b1 * a2)) * (a1 * b2 - b1 * a2) <= 0
      puts "1"
    else
      puts "0"
    end
  end
end
main