{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BS
import Control.Monad

main = do
    s <- BS.getLine
    q <- readLn
    qss <- replicateM q $ BS.words <$> BS.getLine
    BS.putStrLn $ fun s qss

fun :: BS.ByteString -> [[BS.ByteString]] -> BS.ByteString
fun x [[]] = x
fun x (["1"]:xss) = fun (BS.reverse x) xss
fun x (["2","1",y]:xss) = fun (y `BS.append` x) xss
fun x (["2","2",y]:xss) = fun (x `BS.append` y) xss
fun x _ = x