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

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putStrLn $ 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] -> String
solve s qs = toList $ foldl' g (fromList s) qs
  where g !xs Reverse   = rev xs
        g !xs (Add f c) = add c f xs

data DoubleList a = DoubleList ![a] ![a] Bool
  deriving Show

fromList :: [a] -> DoubleList a
fromList xs = DoubleList xs [] True

toList :: DoubleList a -> [a]
toList (DoubleList xs ys True)  = xs ++ reverse ys
toList (DoubleList xs ys False) = ys ++ reverse xs

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

add :: a -> Bool -> DoubleList a -> DoubleList a
add x True (DoubleList xs ys True)   = DoubleList (x:xs) ys True
add x True (DoubleList xs ys False)  = DoubleList xs (x:ys) False
add x False (DoubleList xs ys True)  = DoubleList xs (x:ys) True
add x False (DoubleList xs ys False) = DoubleList (x:xs) ys False
