#include <bits/stdc++.h>

using namespace std;

void solve() {
    string s, ans = "";
    cin >> s;
    for (int i = 0; i < s.size(); i += 3) {
        if (ans.find(s[i]) != string::npos) continue;
        if (!i) ans = ans + s[i];
        else if (s[i - 1] == '>') ans = ans + s[i];
        else if (s[i - 2] == '<') ans = s[i] + ans;
    }
    cout << ans << endl;
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        solve();

    return 0;
}
