n = gets.to_i

n.times do
  order = gets.chomp.chars
  order.delete('-')
  train = []
  li = 0
  ti = 0
  limit = order.size - 3
  train << order[li].bytes.first
  
  until limit < li
    car1 = order[li].bytes.first
    car2 = order[li+2].bytes.first
    way = order[li+1]
    
    if way == '<'
      if train.include?(car2)
        ti -= 1
      else
        train.insert(ti, car2)
      end
    elsif way == '>'
      ti += 1
      train.insert(ti, car2) unless train.include?(car2)
    end
    
    li += 2
  end
  
  puts train.map(&:chr).join
end