#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

int main(){
	int n;
	cin >> n;
	while(n--){
		int pos = 0 , l = 0 , r = 0;
		map<int,char> g;
		string s;
		cin >> s;
		for(int i=0;i<s.size();i+=3){
			g[pos] = s[i];
			if(i == s.size()-1)break;
			if(s[i+1] == '<')pos--;
			else pos++;
		}
		for(map<int,char>::iterator it = g.begin(); it != g.end();++it)
			cout << it->second ;
		cout << endl;
	}
}