#include<iostream>
#include<string>

int main(){
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++){
		char train[60];
		for (int j = 0; j < 60; j++)train[j] = '?';
		int it = 30;

		std::string str;
		std::cin >> str;

		train[it] = str[0];
		for (int j = 1; j < str.size(); j++){
			if (str[j] == '>'){
				it++;
				if (train[it] != str[j + 1])train[it] = str[j + 1];
			}
			else if (str[j] == '<'){
				it--;
				if (train[it] != str[j + 2])train[it] = str[j + 2];
			}
		}

		for (int j = 0; j < 60; j++){
			if (train[j] != '?')std::cout << train[j];
		}
		std::cout << std::endl;
	}
	return 0;
}