import qualified Data.ByteString.Char8 as B
import Data.IORef

main = do
    [s] <- getLine :: IO String
    q <- readLn :: IO Int
    switch <- newIORef False
    res <- newIORef 0

    let
        solve :: B.ByteString -> Int -> IO B.ByteString
        solve bs n
            | n == 0 = return bs
            | otherwise = do
                s <- words <$> getLine
                case (length s) of
                    1 -> do
                        modifyIORef' res (+1)
                        solve bs (n-1)
                    _ -> do
                        res' <- readIORef res
                        let [_,i,[c]] = s
                        case (i, even res') of
                            ("1", True) -> solve (B.cons c bs) (n-1)
                            ("1", False) -> solve (B.snoc bs c) (n-1)
                            ("2", True) -> solve (B.snoc bs c) (n-1)
                            ("2", False) -> solve (B.cons c bs) (n-1)
    b <- solve (B.singleton s) q
    res' <- readIORef res
    putStrLn $ 
        if even res'
            then B.unpack b
            else B.unpack $ B.reverse b
    
