#include<iostream>
#include<string>
using namespace std;
char T[1000000]; int length = 500000, n; string S;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int i = 0; i < 1000000; i++) {
			T[i] == ' ';
		}
		length = 500000;
		cin >> S;
		for (int i = 0; i <= S.size() / 3; i++) {
			T[length] = S[i * 3];
			if (S.size() != i) {
				if (S[i * 3 + 1] == '-') {
					length++;
				}
				else {
					length--;
				}
			}
		}
		for (int i = 0; i < 1000000; i++) {
			if (T[i] != ' ') {
				cout << T[i];
			}
		}
		cout << endl;
	}
}