Problem:
Parallel/Orthogonal

For given two lines s1 and s2, print "2" if they are parallel, "1" if they are orthogonal, or "0" otherwise.

s1 crosses points p0 and p1, and
s2 crosses points p2 and p3.

Input

The entire input looks like:

q (the number of queries)
1st query
2nd query
...
qth query

Each query consists of integer coordinates of the points p0, p1, p2, p3 in the following format:

xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3

Output

For each query, print "2", "1" or "0".

Constraints

1 ≤ q ≤ 1000

-10000 ≤ xpi, ypi ≤ 10000

p0 ≠ p1 and
p2 ≠ p3.

Sample Input 1

3
0 0 3 0 0 2 3 2
0 0 3 0 1 1 1 4
0 0 3 0 1 1 2 2

Sample Output 1

2
1
0

Solution in Haskell (judge verdict: Wrong Answer)

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