#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int cn;
char t[51];
string s;

int main(){
	cin>>cn;
	while(cin>>s){
		fill(t,t+51,0);
		int cur=0,n=25;
		while(1){
			t[n]=s[cur++];
			if(cur==s.size())break;
			if(s[cur]=='-')n++;
			else n--;
			cur+=2;
		}
		for(int i=0;i<51;i++)if(t[i])cout<<t[i];
		cout<<endl;
	}
}