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

using namespace std;

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

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