#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	while (N--) {
		string st; cin >> st;
		int a = 0;
		int now = 26;
		int from = now;
		vector<int>anss(54,-1);
		while (1) {
			if (anss[now] == -1) {
				anss[now] = st[a] - 'a';
			}
			if (a == st.size() - 1)break;
			else {
				if (st[a + 1] == '-') {
					now++;
				}
				else {
					now--;
				}
				from = min(from, now);
			}
			a += 3;
		}
		for (int i = from; i < anss.size(); ++i) {
			if (anss[i] == -1)break;
			else {
				cout << char(anss[i] + 'a');
			}

		}
		cout << endl;
	}
	return 0;
}