def check(x0, y0, x1, y1, x2, y2, x3, y3)
  a1, b1, a2, b2 = x0 - x1, y0 - y1, x2 - x3, y2 - y3
  if a1 * a2 + b1 * b2 == 0
    puts "1"
  elsif a1 * b2 - a2 * b1 == 0
    puts "2"
  else
    puts "0"
  end
end
def main(input = STDIN)
  input.gets.to_i.times{check(*input.gets.split(" ").map(&:to_i))}
end
main