import scala.io.StdIn._

import Math._
object Main extends App {
  val eps0 = 1e-12

  val q = readLine.toInt
  for (i <- 0 until q) {
    val Seq(xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3) = readLine.split(' ').map(_.toDouble).toList
    val sx1 = xp1 - xp0
    val sy1 = yp1 - yp0
    val sx2 = xp3 - xp2
    val sy2 = yp3 - yp2

    val rot = sx1 * sy2 - sy1 * sx2
    val dot = sx1 * sx2 + sy1 * sy2

    println(if (rot.abs < eps0) "2" else if (dot.abs < eps0) "1" else "0")
  }
}

