// 0130
#include <iostream>
#include <deque>
#include <string>
const int C = 'a';
using namespace std;

int main(){
	
	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		string str;
		cin>>str;

		deque<char> dq;
		dq.push_back(str[0]);
		int ch[26] = {0};
		ch[str[0]-C]++;

		for(int j=1;j<str.length();j+=3){
			if((str[j] == '-') && (str[j+1] == '>') && (ch[str[j+2]-C] == 0)){
				dq.push_back(str[j+2]);
				ch[str[j+2]-C]++;
			}

			if((str[j] == '<') && (str[j+1] == '-') && (ch[str[j+2]-C] == 0)){
				dq.push_front(str[j+2]);
				ch[str[j+2]-C]++;
			}
		}

		for(deque<char>::iterator itr = dq.begin();itr != dq.end();itr++)
			cout<<*itr;
		cout<<endl;

	}
	
	
	return 0;
}