#include <cstdio>
#include <iostream>
#include <string>
#include <deque>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		char visited[255] = {};
		string input;
		cin >> input;

		visited[input[0]] = 1;
		deque<char> output;
		output.push_back(input[0]);
		for (int i = 1; input[i]; i += 3){
			if (!visited[input[i + 2]]){
				if (input[i] == '-') output.push_back(input[i + 2]);
				else output.push_front(input[i + 2]);
				visited[input[i + 2]] = 1;
			}
		}
		for (int i = 0; i < output.size(); i++){
			cout << output[i];
		}
		cout << endl;
	}
	return (0);
}