#include <cstdio>
#include <queue>
using namespace std;

int main()
{
	int n;
	
	scanf("%d", &n);
	while (n-- > 0){
		char str[2048] = {0};
		scanf("%s", str);
		
		deque<char> train;
		train.push_back(*str);
		bool v[26] = {false};
		v[*str - 'a'] = true;
		for (int i = 3; str[i] != 0; i += 3){
			if (!v[str[i] - 'a']){
				if (str[i - 1] == '>') train.push_back(str[i]);
				else train.push_front(str[i]);
				v[str[i] - 'a'] = true;
			}
		}
		
		while (!train.empty()){
			putchar(train.front());
			train.pop_front();
		}
		puts("");
	}
	
	return 0;
}