// 2011/02/06 Tazoe

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

int main()
{
	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		string str;
		cin >> str;

		char train[52];
		for(int j=0; j<52; j++)
			train[j] = '/';

		int trn_i = 26;
		train[trn_i] = str[0];

		for(int j=1; j<str.size();){
			if(str[j]=='-'&&str[j+1]=='>')
				trn_i++;
			else if(str[j]=='<'&&str[j+1]=='-')
				trn_i--;
			j += 2;

			train[trn_i] = str[j];
			j++;
		}

		for(int j=0; j<52; j++)
			if(train[j]!='/')
				cout << train[j];
		cout << endl;
	}

	return 0;
}