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

int main() {
    int n;
    cin >> n;
    cin.ignore();
    for (int i=0; i<n; ++i) {
        string res(100, ' '), s;
        getline(cin, s);
        int k = 50;
        res[k] = s[0];
        for (int j=3; j<(int)s.size(); j+=3) {
            if (s[j-1] == '>') {
                k ++;
            } else {
                k --;
            }
            res[k] = s[j];
        }
        string res2 = "";
        for (int i=0; i<100; ++i) {
            if (res[i] != ' ') {
                res2 += res[i];
            }
        }
        cout << res2 << endl;
    }
    return 0;
}