#include<iostream>
using namespace std;
int main(){

    int n;
    cin>>n;
    while(n--){
        int least=30,most=30,now=30;
        string str;
        char ans[60];
        cin>>str;
        ans[30]=str[0];
        for(int i=3;i<str.size();i+=3){
            if(str[i-1]=='>'){
                now++;
                if(most<now)most++;
            }
            else{
                now--;
                if(least>now)least--;
            }
            ans[now] = str[i];
            if(most-least==25)break;
        }
        for(int i=least;i<=most;i++)cout<<ans[i];
        cout<<endl;

    }

    return 0;
}