#include <cstdio>
#include <list>

using namespace std;

int main()
{
	int n;
	char trains[2048];

	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		char train_bucket[256] = {0};
		list<char> ans;

		scanf(" %s", trains);
		
		ans.push_front(*trains);
		train_bucket[*trains] = 1;
		for (int ti = 3; trains[ti] != '\0'; ti++){
			if (!train_bucket[trains[ti]]){
				train_bucket[trains[ti]] = 1;
				if (trains[ti - 1] == '>') ans.push_back(trains[ti]);
				else ans.push_front(trains[ti]);
			}
			if (trains[ti + 1] != '\0') ti += 2; 
		}

		for (list<char>::iterator it = ans.begin(); it != ans.end(); it++){
			printf("%c", *it);
		}
		puts("");
	}

	return (0);
}