#include <iostream>
using namespace std;

int l,r;
char t[3000];

int main(void){
	int n;
	cin>>n;

	while(n--){
		string s;
		cin>>s;
		int idx = 1500;
		l = r = 1500;
		for(int i=0;i<s.length();i+=3){
			if(i != 0){
				if(s[i-1] == '>') idx++;
				else idx--;
				l = min(l,idx);
				r = max(r,idx);
			}
			t[idx] = s[i];
		}
		for(int i=l;i<=r;i++){
			cout<<t[i];
		}
		cout<<endl;
	}

	return 0;
}