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

int main(void){
  int n;
  cin>>n;
  while(n--){
    char data[2048]={'0'};
    char indata[2048];
    int max = 1024;
    int now = 1024;
    int min = 1024;
    cin>>indata;
    data[now]=indata[0];
    for(int i = 1; indata[i] != '\0'; i++){
      if(indata[i]=='>'){now++;max++;}
      else if(indata[i]=='<'){now--;min--;}
      else if(indata[i]=='-')continue;
      if(data[now]!='0')data[now]=indata[i];
    }
    for(int i = min; i <= max;i ++)
      cout<<data[i];
    cout<<endl;
  }
}