import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

newtype Vector a =
    Vector (a, a)
    deriving (Eq, Show)

vector :: a -> a -> Vector a
vector x y = Vector (x, y)

isOrthogonal :: (Num a, Eq a) => Vector a -> Vector a -> Bool
isOrthogonal (Vector (x1, y1)) (Vector (x2, y2))
    = (x1 * x2 + y1 * y2) == 0

isParallel :: (Num a, Ord a) => Vector a -> Vector a -> Bool
isParallel (Vector (x1, y1)) (Vector (x2, y2))
    = if x1 < x2
      then (x1 * y2 - x2 * y1) == 0
      else (x2 * y1 - x1 * y2) == 0

solve :: [[Int]] -> IO ()
solve [] = return ()
solve ([x0, y0, x1, y1, x2, y2, x3, y3]:ps) = do
    let v1 = vector (x1 - x0) (y1 - y0)
    let v2 = vector (x3 - x2) (y3 - y2)
    case () of
        _ | isParallel v1 v2   -> putStrLn "2"
          | isOrthogonal v1 v2 -> putStrLn "1"
          | otherwise          -> putStrLn "0"
    solve ps

main :: IO ()
main = do
    q <- readLn
    qs <- fmap (fmap readi . B.words) <$> replicateM q B.getLine
    solve qs

