import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ls <- replicateM n getLine
  let ansL = map ordAlpha' ls
  mapM_ putStrLn ansL

ordAlpha :: String -> String -> Int -> Int -> Int -> String
ordAlpha "" save _ _ _ = save
ordAlpha (c:rs) "" p l h = ordAlpha rs (c:[]) p l h
ordAlpha ('-':'>':c:rs) save p l h
  | p == h = ordAlpha rs (save++(c:[])) (p+1) l (h+1)
  | otherwise = ordAlpha rs save (p+1) l h
ordAlpha ('<':'-':c:rs) save p l h
  | p == l = ordAlpha rs (c:save) (p-1) (l-1) h
  | otherwise = ordAlpha rs save (p-1) l h

ordAlpha' :: String -> String
ordAlpha' ss = ordAlpha ss "" 0 0 0