#include<cstdio>
#include<cstring>
#include<cstring>
using namespace std;
int main(){
	
	int n;
	scanf("%d",&n);
	
	for(int q = 0;q < n; q++){
		
		char str[1000] = {0};
		scanf("%s",str);
		
		char ans[1000] = {0};
		
		ans[0] = str[0];
		
		bool check[1280] = {0};
		
		check[str[0]] = 1;
		
		int x = 1;
		for(int i = 3; i < strlen(str); i+=3){
			
			if(check[str[i]] == 1)continue;
			check[str[i]] = 1;
			
			if(str[i-1] == '>'){
				ans[x] = str[i];
				x++;
			}
			else if(str[i-2] == '<'){
				for(int j = x;j > 0; j--)ans[j] = ans[j-1];
				ans[0] = str[i];
				x++;
			}
		}
		
		printf("%s\n",ans);
		
	}
	return 0;
}