https://www.acmicpc.net/problem/5397
count = int(input())
for _ in range(count):
case = [_ for _ in input()]
left_stack, right_stack = [], []
for char in case:
if char == ">":
if right_stack:
left_stack.append(right_stack.pop())
elif char == "<":
if left_stack:
right_stack.append(left_stack.pop())
elif char == "-":
if left_stack:
left_stack.pop()
else:
left_stack.append(char)
left_stack += right_stack[::-1]
print(''.join(left_stack))
from sys import stdin
for _ in range(int(stdin.readline())):
typing = stdin.readline().strip()
left, right = [], []
for type in typing:
if type == '<':
if left:
right.append(left.pop())
elif type == '>':
if right:
left.append(right.pop())
elif type == '-':
if left:
left.pop()
else:
left.append(type)
left.extend(reversed(right))
print(''.join(left))
test_case = int(input())
for _ in range(test_case):
left_stack = []
right_stack = []
data = input()
for i in data:
if i == '-':
if left_stack:
left_stack.pop()
elif i == '<':
if left_stack:
right_stack.append(left_stack.pop())
elif i == '>':
if right_stack:
left_stack.append(right_stack.pop())
else:
left_stack.append(i)
left_stack.extend(reversed(right_stack))
print(''.join(left_stack))