eps = 1e-12
q = gets.to_i
q.times{
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  v0x = x1 - x0
  v0y = y1 - y0
  v1x = x3 - x2
  v1y = y3 - y2
  ct = (v0x*v1x+v0y*v1y)/Math.sqrt(v0x**2+v0y**2)/Math.sqrt(v1x**2+v1y**2)
  if (ct.abs - 1.0).abs < eps
    puts 2
  elsif ct.abs < eps 
    puts 1
  else
    puts 0
  end
}