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

int main() {
	int n;
	cin >> n;

	for (int a = 0;a < n;a++) {
		string s;
		string ans;
		cin >> s;

		ans = s[0];

		int b = s.size();
		for (int i = 0;i < b / 3;i++) {
			if (s[(i + 1) * 3 - 1] == '>') {
				size_t za = ans.find(s[(i + 1) * 3]);
				if (za == string::npos)ans += s[(i + 1) * 3];
			}
			else if (s[i * 3 + 1] == '<') {

				size_t zb = ans.find(s[(i + 1) * 3]);
				if (zb == string::npos) {
					string sb;
					sb= s[(i + 1) * 3];
					sb += ans;
					ans = sb;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}