#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        vector<bool> used(2000,false);
        deque<char> deq;
        
        bool f=false;
        int pos = 1000;
        for(int i=0;i<s.size();i+=3){
            if(used[pos]==false){
                if(f==false || used[pos+1]==true){
                    f=true;
                    deq.push_front(s[i]);
                }else{
                    deq.push_back(s[i]);
                }
                used[pos]=true;
            }
            if(i+1>=s.size())continue;
            assert(s[i+1]=='<' || s[i+2]=='>');
            if(s[i+1]=='<')pos--;
            else if(s[i+2]=='>')pos++;
        }
        for(auto e:deq)cout<<e;
        cout<<endl;
    }
}