#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const* argv[])
{
	string input;
	char answer[64];
	int n;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> input;
		for( int j = 0;j < 64;j++ ) answer[j] = '\0';
		int pos = 32;

		answer[pos] = input[0];
		for( int j = 3;j < input.size();j += 3 ){
			if( input[j - 2] == '<' ){
				pos--;
				answer[pos] = input[j];
			} else if( input[j - 2] == '-' ){
				pos++;
				answer[pos] = input[j];
			}
		}

		int j;
		for( j = 0;j < 64;j++ ){
			if( answer[j] != '\0' ) break;
		}

		cout << ( answer + j ) << endl;
	}
				

	return 0;
}