main = getContents >>= putStrLn.unwords.map show.foldl1 (zipWith (+)).map (f.words).tail.lines
    where f (x:y:_) | x > y  = [3,0]
                    | x < y  = [0,3]
                    | x == y = [1,1]