{-# LANGUAGE BangPatterns #-}
import           Control.Monad (replicateM)
import           Data.List     (foldl')

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putDoubleStringLn $ solve s qs

data Query = Reverse | Add Bool Char

getQuery :: IO Query
getQuery = do
  (t:xs) <- words <$> getLine
  if t == "1"
    then return Reverse
    else let [f, c] = xs in return $ Add (f == "1") (head c)

solve :: String -> [Query] -> DoubleString
solve s qs = foldr g (fromString s) (reverse qs)
  where g Reverse xs   = rev xs
        g (Add f c) xs = add c f xs

data DoubleString = DoubleString String String Bool
  deriving Show

putDoubleStringLn :: DoubleString -> IO ()
putDoubleStringLn (DoubleString xs ys True) = do
  putStr xs
  putStrLn $ reverse ys
putDoubleStringLn (DoubleString xs ys False) = do
  putStr ys
  putStrLn $ reverse xs

fromString :: String -> DoubleString
fromString xs = DoubleString xs [] True

toString :: DoubleString -> String
toString (DoubleString xs ys True)  = xs ++ reverse ys
toString (DoubleString xs ys False) = ys ++ reverse xs

rev :: DoubleString -> DoubleString
rev (DoubleString xs ys f) = DoubleString xs ys $ not f

add :: Char -> Bool -> DoubleString -> DoubleString
add x True (DoubleString xs ys True)   = DoubleString (x:xs) ys True
add x True (DoubleString xs ys False)  = DoubleString xs (x:ys) False
add x False (DoubleString xs ys True)  = DoubleString xs (x:ys) True
add x False (DoubleString xs ys False) = DoubleString (x:xs) ys False
