data Turn = A | B deriving(Eq)

next_turn t
  | t == A    = B
  | otherwise = A

-- (??????, (A????????°,B????????°), Out?????°, ????????¶???)
act :: (Turn, (Int, Int), Int, [Int]) -> String -> (Turn, (Int, Int), Int, [Int]) 

act (turn, (a,b), out, base) "OUT" 
  | out == 2  = (next_turn turn, (a,b), 0, [0,0,0])
  | otherwise = (turn, (a,b), out+1, base)
act (A, (a,b), out, base) "HOMERUN"
  = (A, (a + (sum base) + 1, b), out, [0,0,0])
act (B, (a,b), out, base) "HOMERUN"
  = (B, (a, b + (sum base) + 1), out, [0,0,0])
act (A, (a,b), out, (x1:x2:x3:_)) "HIT"
  = (A, (a+x3,b), out, (1:x1:x2:[]))
act (B, (a,b), out, (x1:x2:x3:_)) "HIT"
  = (B, (a,b+x3), out, (1:x1:x2:[]))

play :: (Turn, (Int, Int), Int, [Int]) -> [String] -> (Int, Int)
play (_, (a,b), _, _) [] = (a, b)
play state (p:ps) = 
  let next_state = act state p
  in
    play next_state ps

main = do
  c <- getContents
  let l = drop 1 $ lines c
      (a,b) = play (A, (0,0), 0, [0,0,0]) l
  print a
  print b