module Main where

newtype Ball = Ball (String, Int) deriving (Show)

choice :: Ball -> String -> Bool
choice (Ball (b, _)) b' | b == b'   = True
                        | otherwise = False

decNum :: Ball -> Ball
decNum (Ball (b, n)) = Ball (b, n-1)

ballNum :: Ball -> Int
ballNum (Ball (_, n)) = n

main :: IO ()
main = do
  bs <- getLine
  ns <- getLine
  b  <- getLine
  let nn    = map read $ words ns :: [Int]
  let balls = zipWith (curry Ball) (words bs) nn
  putStrLn $ unwords $ map (show . (\x -> if choice x b then ballNum $ decNum x else ballNum x)) balls
