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

int n;
string s;
list<char> ls;

int main(){
	cin >> n;
	for(int I = 0; I < n; I++){
		cin >> s;
		ls = list<char>();
		ls.push_back(s[0]);
		list<char>::iterator itr = ls.begin();
		for(int i = 3; i < s.size(); i+=3){
			if(s[i-1] == '-'){
				if(itr == ls.begin()){
					ls.push_front(s[i]);
				}
				itr--;
			}
			else{

				if(++itr == ls.end()){
					ls.push_back(s[i]);
					itr = ls.end();
					itr--;
				}
			}
		}
		for(list<char>::iterator i = ls.begin(); i != ls.end(); i++){
			cout << *i;
		}
		cout << endl;
	}
	return 0;
}