module ABC158.D where

import Control.Monad (replicateM)
import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (unpack)

toString::(Bool,String)->String
toString (True,s) = s
toString (False,s) = reverse s

main = do
  s <- getLine
  q <- readLn
  qn <- replicateM q BS.getLine::IO[BS.ByteString]
  let p = toString $ foldl (\(r, acc) p -> case words (unpack p) of
            ["2","1",c] -> if r then (r,c ++ acc) else (r,acc ++ c)
            ["2","2",c] -> if r then (r,acc ++ c) else (r,c ++ acc)
            _ -> (not r, acc)) (True,s) qn
  putStrLn $ p