#include<iostream>
#include<algorithm>
#include<string>
#include<list>


using namespace std;


int main()
{
	int n;
	string t;
	list<char> l;

	ios::sync_with_stdio(false);

	cin >>n;

	for (int i = 0; i != n; ++i)
	{
		cin >> t;
		l.push_back(t.at(0));
		for (unsigned int j = 1; j != t.size();++j)
		{
			if (t.at(j) == '>')
			{
				if (find(l.begin(),l.end(),t.at(j + 1)) == l.end())
				{
					l.push_back(t.at(j + 1));
				}
				
			}
			else if(t.at(j)=='<')
			{
				if (find(l.begin(), l.end(), t.at(j + 2)) == l.end())
				{
					l.push_front(t.at(j + 2));
				}
			}
		}
		for (list<char>::iterator it=l.begin(); it != l.end(); ++it)
		{
			cout << *it;
		}
		cout << endl;
		l.clear();
	}

	return 0;

}
