#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-5;

using namespace std;

int main()
{
	char buf[1024 + 256];
	cin.getline(buf, sizeof(buf));
	int n;
	sscanf(buf, "%d", &n);
	while (n--)
	{
		cin.getline(buf, sizeof(buf));
		strcat(buf, "--");
		pair<int, char> pos[26];
		for (int i = 0; i < 26; ++i)
		{
			pos[i].first = 9999;
			pos[i].second = i + 'a';
		}
		int relaPos = 0;
		for (int i = 0; buf[i] != '\0'; i += 3)
		{
			pos[buf[i] - 'a'].first = relaPos;
			if (buf[i + 2] == '>')
				++relaPos;
			else
				--relaPos;
		}
		sort(pos, pos+26);
		for (int i = 0; pos[i].first != 9999 && i < 26; ++i)
			putchar(pos[i].second);
		putchar('\n');
	}

	return 0;
}