# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int n;
	cin >> n;
	for (int o = 0; o < n; o++) {
		string s;
		cin >> s;
		string ans;
		bool count[1000];
		for (int i = 0; i < 1000; i++)count[i] = false;
		ans += s[0];
		count[s[0]] = true;
		for (int i = 1; i < s.size(); i += 3) {
			if (s[i + 1] == '>' && !count[s[i + 2]])ans = ans + s[i + 2], count[s[i + 2]] = true;
			else if (s[i] == '<' && !count[s[i + 2]])ans = s[i + 2] + ans, count[s[i + 2]] = true;
		}
		cout << ans << endl;
	}
}