import Control.Monad

data Query = One | Two Int Char deriving (Show, Eq)


sousa :: Query -> String -> String
sousa One str = reverse str
sousa (Two 1 c) str = c:str
sousa (Two 2 c) str = str ++ [c]

main = do
  str <- getLine
  q <- read <$> getLine
  qs <- forM [1..q] $ \n -> do
    query <- getLine
    return $ if head query == '1'
       then One
       else let [f, c] = tail (words query) in Two (read f) (head c)
  putStrLn $ foldl (flip sousa) str qs