import Data.List
import Data.Char
import Text.Printf

main = interact $ show' . solve . read'
  where
    show' xs = (unwords [showA xs, showB xs]) ++ "\n"
    showA = show . sum
    showB = show . sum . flip
    solve [] = []
    solve ([a, b]:xs) | a == b    = 1:(solve xs)
                      | a <  b    = 0:(solve xs)
                      | otherwise = 3:(solve xs)
    flip = map flipOne
      where flipOne x | x == 0 = 3
                      | x == 3 = 0
                      | otherwise = 1
    read' = map words . tail . lines :: String -> [[String]]

