def parallel? u, v
  (u.conj * v).imag.zero?
end

gets.to_i.times do
  p0, p1, p2, p3 = gets.split.map(&:to_i).each_slice(2).map {|a, b| a + b * 1i }
  u, v = p1 - p0, p3 - p2
  p [u, -u].any? {|z| parallel? z, v } ? 2 : [u * 1i, u * -1i].any? {|z| parallel? z, v } ? 1 : 0
end