import Control.Applicative

main :: IO ()
main = solve <$> words <$> getLine <*> f <*> getLine >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [String] -> [Int] -> String -> String
solve [s, _] [a, b] u
  | s == u = unwords $ map show [a-1, b]
  | otherwise = unwords $ map show [a, b-1]
