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

int main()
{
	int i;
	string s;
	list<char> l;
	list<char>::iterator it;
	getline(cin,s);
	while (getline(cin,s)) {
		l.clear();
		i = 0;
		l.push_back(s[0]);
		it = l.begin();
		while (++i<s.size()) {
			if (s[i++]=='<') {
				if (*(--it)++ != s[++i]) l.insert(it,s[i]);
				it--;
			} else if (s[i]=='>') {
				if (*(++it) != s[++i]) {
					l.insert(it,s[i]);
					it--;
				}
			}
		}
		for (it = l.begin(); it != l.end(); it++) cout<<*it;
		cout<<endl;
	}
	return 0;
}