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

int main() {
	int N;
	cin >> N;
	while (N--) {
		string str;
		cin >> str;

		list<char> dt;
		list<char>::iterator it = dt.begin();
		bool r;
		dt.push_back(str[0]); it++;
		for (int i=1; i<str.size(); i++)
			if (i%3==0)
				if (r) {
					if (it == --dt.end()) dt.push_back(str[i]);
					it++;
				} else { 
					if (it == dt.begin()) dt.push_front(str[i]);
					it--;
				}
			else
				r = (str[i++]=='-') ? true : false;

		it = dt.begin();
		while (it != dt.end())
			cout << *(it++);
		cout << endl;
	}
	return 0;
}