import Control.Applicative ((<$>))
import Control.Monad
import Data.Complex

type Vector = Complex Double

eps :: Double
eps = 1e-7

dot :: Vector -> Vector -> Double
dot a b = realPart $ conjugate a * b

cross :: Vector -> Vector -> Double
cross a b = imagPart $ conjugate a * b

readWords :: Read a => IO [a]
readWords = map read . words <$> getLine

main :: IO ()
main = do
  q <- readLn
  qs <- replicateM q $ do
    [x0,y0,x1,y1,x2,y2,x3,y3] <- readWords :: IO [Double]
    let
      p0 = x0:+y0
      p1 = x1:+y1
      p2 = x2:+y2
      p3 = x3:+y3
    return (p0,p1,p2,p3)

  forM_ qs $ \(p0,p1,p2,p3) -> do
    let
      para = abs ((p1-p0)`cross`(p3-p2)) < eps
      orth = abs ((p1-p0)`dot`(p3-p2)) < eps
    when para $ print 2
    when orth $ print 1
    when (not para && not orth) $ print 0