#include <iostream>
using namespace std;

typedef string::iterator S;

struct Node{
    char id;
    Node* prev;
    Node* next;
};

int main(){
    int n,i;
    cin>>n;
    while(n--){
        string expr;
        cin>>expr;
        Node vs[26];
        for(i=0;i<26;i++){
            vs[i].id=0;
            vs[i].prev=NULL;
            vs[i].next=NULL;
        }
        Node* vp = vs;
        Node* fr = vp+1;
        Node* head = vp;
        S s = expr.begin();
        while( true ){
            vp->id = *s;
            s++;
            if( s == expr.end() ) break;
            if( *s == '-' ){
                if( vp->next == NULL ){
                    vp->next = fr;
                    (vp->next)->prev = vp;
                    fr++;
                }
                vp = vp->next;
            }else{
                if( vp->prev == NULL ){
                    vp->prev = fr;
                    (vp->prev)->next = vp;
                    fr++;
                    head = vp->prev;
                }
                vp = vp->prev;
            }
            s += 2;
        }
        while( head ){
            cout << head->id;
            head = head->next;
        }
        cout << endl;
    }
    return 0;
}