import Control.Monad

data Line = Vert Double | Line { slope :: Double
                               , interact :: Double
                               } deriving Show

main = do
  n <- readLn
  replicateM_ n solve

solve :: IO ()
solve = do
  [x0,y0,x1,y1,x2,y2,x3,y3] <- fmap (map read.words) getLine
  let (l1,l2) = (corrLine (x0,y0) (x1,y1), corrLine (x2,y2) (x3,y3))
  putStrLn $ checkCrossAngle l1 l2

checkCrossAngle l1 l2
  | isParallel l1 l2 = "2"
  | isOrthogonal l1 l2 = "1"
  | otherwise = "0"

isVert :: Line -> Bool
isVert (Vert _) = True
isVert (Line _ _) = False

isParallel :: Line -> Line -> Bool
isParallel l1 l2
  | isVert l1 = isVert l2
  | isVert l2 = False
  | otherwise = slope l1 == slope l2

isOrthogonal :: Line -> Line -> Bool
isOrthogonal l1 l2
  | isVert l1 && isVert l2 = False
  | isVert l1 = slope l2 == 0
  | isVert l2 = slope l1 == 0
  | otherwise = slope l1 * slope l2 == -1

corrLine (x1,y1) (x2,y2)
  | x1 == x2 = Vert x1
  | otherwise = Line a b
  where a = (y2 - y1) / (x2 - x1)
        b = y1 - a*x1