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

main = abc158D

abc158D :: IO()
abc158D = do
  s <- BS.getLine
  [q] <- getIntList
  qs <- replicateM (fromIntegral q) BS.getLine
  putStrLn . BS.unpack $ operation s qs

type Query = BS.ByteString
operation :: BS.ByteString -> [Query] -> BS.ByteString
operation s [q] = exec s $ BS.unpack q
operation s (q:qs) = operation (exec s $ BS.unpack q) qs

exec :: BS.ByteString -> String -> BS.ByteString
exec s ['1'] = BS.reverse s
exec s ('2':q) = case q!!1 of '1' -> BS.cons (q!!3) s
                              '2' -> BS.reverse $ BS.cons (q!!3) (BS.reverse s)

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