#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n;i++) {
		string buf;
		cin >> buf;
		int pos = 0;
		deque<char> list;
		list.push_back(buf[0]);
		for (auto it = buf.begin()+1; it < buf.end(); it += 3) {
			if (*it == '-')pos++;
			else pos--;
			if (pos == list.size())list.push_back(*(it + 2));
			else if (pos < 0) {
				pos = 0;
				list.push_front(*(it + 2));
			}
		}
		string s(list.begin(), list.end());
		cout << s << endl;
	}
	return 0;
}