#include <iostream>
#include <string>
using namespace std;

int check(char s[100], char c){
	for(int i=0 ; i < 100 ; i++ ){
		if( s[i] == c ) return i;
	}
	return -1;
}

int main(){
	int n;
	cin >> n;
	for(int i=0 ; i< n ; i++ ){
		string s;
		cin >> s;

		char f[100];
		for(int i=0 ; i < 100 ; i++ )
			f[i] = '*';
		f[50] = s[0];

		for(int i=1 ; i < s.size() ; i+=3 ){
			char prev = s[i-1];
			char next = s[i+2];
			int j = check( f , prev );
			if( s[i] == '-' ){
				f[j+1] = next;
			}
			if( s[i] == '<' ){
				f[j-1] = next;
			}
		}
		for(int i=0 ; i < 100 ; i++ ){
			if( f[i] != '*' ){
				cout << f[i];
			}
		}
		cout << endl;
	}
}