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

using namespace std;

int main()
{
	int n;	cin>>n;
	while(n--){
		string tr;	cin>>tr;
		deque<char> dq(1,tr[0]);
		deque<char>::iterator it=dq.begin();

		for(int i=1;i<tr.length();i+=3){
			if(tr[i]=='-'){	// forward
				it++;
				if(it==dq.end())	dq.push_back(tr[i+2]);
			}
			else{			// backward
				if(it==dq.begin())	dq.push_front(tr[i+2]);
				it--;
			}
		}

		for(it=dq.begin();it!=dq.end();it++)	cout<<*it;
		cout<<endl;
	}

	return 0;
}