#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P,P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n;
    cin >> n;
    REP(i,n){
        string s;
        cin >> s;
        deque<char> train;
        train.push_back(s[0]);
        int pos = 0, l = 0, r = 0;
        for(int j=1;j*3<=int(s.size());j++){
            if(s[j*3-1]=='>'){
                if(pos==r){
                    train.push_back(s[j*3]);
                    r++;
                }
                pos++;
            }
            else{
                if(pos==l){
                    train.push_front(s[j*3]);
                    l--;
                }
                pos--;
            }
        }
        for(auto c : train){
            cout << c;
        }
        cout << endl;
    }
    return 0;
}

