#include <iostream>
#include <string>
#include <deque>

using namespace std;

int main(void)
{
	int n;
	string str;
	
	cin >> n;
	while (n--){
		cin >> str;
		
		deque <char> d;
		d.push_back(str[0]);
		bool done[30] = {false};
		done[str[0] - 'a'] = true;
		for (int i = 3; i < str.length(); i += 3){
			int now = str[i] - 'a';
			if (done[now]) {
				// cout << i << " vst" << endl;
				continue;
			}
			if (str[i - 1] == '>'){
				d.push_back(str[i]);
				done[now] = true;
			}
			else {
				d.push_front(str[i]);
				done[now] = true;
			}
		}
		for (int i = 0; i < d.size(); i++){
			cout << d[i];
		}
		cout << endl;
	}
	
	return 0;
}