#include <iostream>
#include <string>
#include <list>
#include <cstring>
using namespace std;

int main(){
	int n,sw;
	bool f[30];
	string str;
	list<char> li;
	cin >> n;
	for(int i = 0;i < n;++i){
		sw = 0;
		memset(f,0,sizeof(f));
		li.clear();
		cin >> str;
		for(int j = 0;j < str.size();++j){
			if(str[j] == '<') sw = 0;
			else if(str[j] == '>') sw = 1;
			else if(str[j] != '-'){
				if(!f[(int)(str[j] - 'a')]){
					if(sw) li.push_back(str[j]);
					else li.push_front(str[j]);
				}
				f[(int)(str[j] - 'a')] = true;
			}
		}
		list<char>::iterator it = li.begin();
		while(it != li.end()){
			cout << *it;
			++it;
		}
		cout << endl;
	}
}