//16
#include<iostream>
#include<deque>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    char l[1025];
    cin>>l;
    deque<char> deq;
    deq.push_back(l[0]);
    int idx=0;
    for(int i=1;l[i];i+=3){
      if(l[i]=='-'){
	idx++;
	if(idx>=deq.size()){
	  deq.push_back(l[i+2]);
	}
      }else{
	idx--;
	if(idx<0){
	  deq.push_front(l[i+2]);
	  idx=0;
	}
      }
    }
    for(int i=0;i<deq.size();i++){
      cout<<deq[i];
    }
    cout<<endl;
  }
  return 0;
}