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 <- map BS.words <$> 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 $ map BS.unpack q
operation s (q:qs) = operation (exec s $ map BS.unpack q) qs

exec :: BS.ByteString -> [String] -> BS.ByteString
exec s [['1']] = BS.reverse s
exec s [['2'],[x],[c]] = case x of '1' -> BS.cons c s
                                   '2' -> BS.reverse $ BS.cons c (BS.reverse s)

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