require 'matrix'
q = gets.to_i
q.times do
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
  s1 = Vector[ x1 - x0, y1 - y0, 0 ]
  s2 = Vector[ x3 - x2, y3 - y2, 0 ]
  if s1.inner_product(s2) == 0
    puts 1
  elsif s1.cross_product(s2).norm == 0
    puts 2
  else
    puts 0
  end
end