import Control.Monad

main = do
  n <- getLine
  q <- readLn
  a <- map words <$> replicateM q getLine
  
  putStrLn $ f True n a
  
f :: Bool -> String -> [[String]] -> String
f b ss [] 
  | b = ss
  | otherwise = reverse ss
f b ss (x:xs) 
  | length x == 1 = f (not b) ss xs
  | otherwise = f b (f2 b ss x) xs
  
f2 :: Bool -> String -> [String] -> String
f2 b s [_,x,y]
  | x == "1" && b = y ++ s
  | x == "1" && not b = s ++ y
  | x == "2" && b = s ++ y
  | otherwise = y ++ s
 
