_ = gets
while l = gets do
  ps = l.split(' ').map(&:to_i)
  va = [ps[2] - ps[0], ps[3] - ps[1]]
  vb = [ps[6] - ps[4], ps[7] - ps[5]]
  sp = va[0] * vb[0] + va[1] * vb[1]
  vp = va[0] * vb[1] - vb[0] * va[1]
  if vp == 0
    puts 2
  elsif sp == 0
    puts 1
  else
    puts 0
  end
end
