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 $ operation (BS.unpack s) (map BS.unpack qs)

type Query = String
operation :: String -> [Query] -> String
operation s [q] = exec s q
operation s (q:qs) = operation (exec s q) qs

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

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