def solve(ln)
  op=ln.gsub(/[a-z]/,"").scan(/../)
  car=ln.split(/->|<-/)
  abort "Input strange in 'solve'" if  car.length != op.length + 1
  v = []
  i=0
  return [] if car.length==0
  v.push(car.shift)
  while op.length >0 do
    dir = op.shift
    abort ("car strange in solve") if car.length==0
    x = car.shift
    if dir == "->" then
      i += 1
    else
      i -= 1
    end
    if i == v.length then
      v.push(x)
    elsif i < 0 then
      v.unshift(x)
      i = 0
    elsif v[i] != x then
      abort("Something is strange")
    else
    #  puts("ok #{x}")
    end
  end

  return v.join
end

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0130.txt")
  end
  n= fh.gets.chomp.to_i
  jyun = []
  0.upto(n-1){|i|
    ln = fh.gets.chomp
    jyun.push(ln)
  }

  0.upto(n-1){|i| puts solve(jyun[i])}
end

if $0 == __FILE__ then
  main
end

=begin
# test_sample.rb
require 'test/unit'
class TestSample < Test::Unit::TestCase
  def test_solve
    assert_equal solve("a->e->c->b->d"), "aecbd"
    assert_equal solve("b<-c<-a<-d<-e"), "edacb"
    assert_equal solve("b->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d"),"bacde"
    assert_equal solve("a->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c"), "bcdae"
  end
end
=end