import Control.Applicative
import Data.List

main = do _ <- getLine
          cards <- map words . lines <$> getContents
          putStrLn . unwords . map show $ solve cards

solve :: [[String]] -> [Int]
solve cards = map sum . transpose $ map judge cards

judge :: [String] -> [Int]
judge (t:h:_) | t == h = [1,1]
              | t > h = [3,0]
              | otherwise = [0,3]