#include <iostream>
#include <deque>
#include <string>
#include <map>

using namespace std;

int main(void){
  int n;

  cin >> n;
  cin.ignore();
  for(int i=0;i<n;i++){
	map<int,char> m;
	int pos=0;
	string str;
	char tmp[2];

	
	getline(cin,str);
	int len = str.size();

	for(int j=0;j<len;j++){
	  if(m.find(pos) == m.end()){
		m[pos] = str[j];
	  }
	  if(j == len-1) break;
	  tmp[0] = str[++j];
	  tmp[1] = str[++j];
	  if(tmp[0] == '-'){
		pos++;
	  }else{
		pos--;
	  }
	}
	map<int,char>::iterator it = m.begin();

	while(it != m.end()){
	  cout << (*it).second;
	  ++it;
	}
	cout << endl;
  }
}