#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	string s;
	cin>>n;
	rep(j,0,n){
		cin>>s;
		string ans="";
		ans=ans+s[0];
		rep(i,0,s.size()/3){
			if(ans.find(s[3*i+3])!=string::npos) continue;
			if(s[3*i+2]=='>'){
				ans=ans+s[3*i+3];
			}else{
				ans=s[3*i+3]+ans;
			}
		}
		cout<<ans<<endl;
	}
}