import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getQuery = do
  l <- words <$> getLine
  case l of
    ["1"]           -> return (1, 0, 'x')
    ["2", n, (c:_)] -> return (2, (read n :: Int), c)

main = do
  s <- getLine
  n <- getInt
  qs <- replicateM n getQuery

  let solve s m [] = if (m .&. 1) == 1 then reverse s else s
      solve s m ((1,_,_):qs') = solve s (m+1) qs'
      solve s m ((2,f,c):qs') =
        if (f == 1 && (m .&. 1) == 0) || (f == 2 && (m .&. 1) == 1)
        then solve (c:s) m qs'
        else solve (s++[c]) m qs'

  putStrLn $ solve s (0::Int) qs