#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		string train;
		cin >> train;

		string kotae = "";
		int c = 1;
		kotae += train[0];

		while ( c < train.size() )
		{
			if ( train[c] == '-' )
			{
				if ( kotae.find( train[c+2] ) == string::npos )
				{
					kotae += train[c+2];
				}
			}
			else if ( train[c] == '<' )
			{
				if ( kotae.find( train[c+2] ) == string::npos )
				{
					kotae = train[c+2] + kotae;
				}
			}
			c += 3;
		}
		cout << kotae << endl;
	}
	return 0;
}