#include <iostream>
#include <list>
#include <set>
#include <string>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		list<char> List;
		set<char> Set;
		string str;
		cin >> str;
		List.push_back(str[0]);
		Set.insert(str[0]);
		for(int i = 2; i < str.size(); ++i)
		{
			if('a' <= str[i] && str[i] <= 'z')
			{
				if(!Set.count(str[i]))
				{
					if(str[i - 1] == '>')
					{
						List.push_back(str[i]);
					}
					else
					{
						List.push_front(str[i]);
					}
					Set.insert(str[i]);
				}
			}
		}
		for(list<char>::iterator Ite = List.begin(); Ite != List.end(); ++Ite)
		{
			cout << *Ite;
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}