fun main(args: Array<String>) {

    val q = readLine()!!.toInt()
    repeat(q) {
        val ps = readLine()!!.split(' ').map { it.toInt() }
        val s1 = T2A.Segment(T2A.Point(ps[0], ps[1]), T2A.Point(ps[2], ps[3]))
        val s2 = T2A.Segment(T2A.Point(ps[4], ps[5]), T2A.Point(ps[6], ps[7]))
        println(if (s1.isOrthogonal(s2)) 1 else if (s1.isParallel(s2)) 2 else 0)
    }

}

private class T2A {

    data class Point(val x: Int, val y: Int) {

        fun dot(p: Point): Int {
            return x * p.x + y * p.y
        }

        fun cross(p: Point): Int {
            return x * p.y - y * p.x
        }

        operator fun minus(p: Point): Point {
            return Point(x - p.x, y - p.y)
        }

    }

    data class Segment(val p1: Point, val p2: Point) {

        fun isOrthogonal(s: Segment): Boolean {
            return (p2 - p1).dot(s.p2 - s.p1) == 0
        }

        fun isParallel(s: Segment): Boolean {
            return (p2 - p1).cross(s.p2 - s.p1) == 0
        }

    }

}

