main = getContents >>= putStrLn . unwords . itp1_9_c . map words . tail . lines

itp1_9_c cs = match 0 0 cs
 where
  match t h [] = [show t, show h]
  match t h ([ct,ch]:xs)
   | ct > ch  = match (t+3) h xs
   | ct == ch = match (t+1) (h+1) xs
   | ct < ch  = match t (h+3) xs