#include <iostream>
#include <queue>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	cin >> n;
	while(n--) {
		deque<char> q;
		bool ch[26] = {};
		string s;
		cin >> s;
		q.push_back(s[0]);
		ch[s[0]-'a'] = 1;
		int ren = (s.length()-1)/3;
		rep2(i,1,ren+1) {
			if(s[i*3-2] == '<' && !ch[s[i*3]-'a']) {
				q.push_front(s[i*3]);
				ch[s[i*3]-'a'] = 1;
			} else if(s[i*3-1] == '>' && !ch[s[i*3]-'a']) {
				q.push_back(s[i*3]);
				ch[s[i*3]-'a'] = 1;
			}
		}
		for(char c : q) {
			cout << c;
		}
		cout << endl;
	}
	return 0;
}