#include <iostream>
#include <string>
using namespace std;
int main(){
	string base,a,b,c;
	int n;
	int f[27];
	for(cin>>n;n>0;n--){
		cin>>base;
		a=b=c="";
		for(int i=0;i<=26;i++)f[i]=0;
		for(int i=0;i<base.size();i+=3){
			if(f[base[i]-96]==0){
				f[base[i]-96]=1;
				if(a.size()==0)a+=base[i];
				else{
					if(base[i-1]=='>')a+=base[i];
					else{
						b=a;
						a="";
						a+=base[i];
						a+=b;
					}
				}
			}
			
		}
		cout<<a<<endl;
		
	}
	
	return 0;
}
