#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

void dfs(int n,vector<int> e[26],bool used[26]){
	if(used[n]) return;
	used[n] = true;
	for(int i=0;i<e[n].size();i++){
		dfs(e[n][i],e,used);
	}
	printf("%c",'a'+n);
}

int main(){
	int N;
	cin>>N;
	for(int ds=0;ds<N;ds++){
		vector<int> e[26];
		bool used[26]; fill_n(used,26,true);
		string S;
		cin>>S;
		for(int i=0;i<S.size();i++){
			if(isalpha(S[i])) used[S[i]-'a'] = false;
			int a = S[i-1]-'a', b = S[i+2]-'a';
			if(S[i]=='-' && S[i+1]=='>'){
				e[b].push_back(a);
			}
			else if(S[i]=='<' && S[i+1]=='-'){
				e[a].push_back(b);
			}
		}
		for(int i=0;i<26;i++) if(used[i]==false) dfs(i,e,used);
		puts("");
	}
	return 0;
}