#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main(){
  int in;
  cin >> in;
  char trash;
  scanf("%c",&trash);
  for(int i = 0; i < in; i++){
    string str;
    getline(cin,str);
    string out;
    out += str[0];
    for(int j = 1; j < str.length(); j+=3){
      if(str[j+1] == '>'){
	int status = 1;
	for(int k = 0; k < out.length(); k++){
	  if(out[k] == str[j+2]) status = 0;
	}
	if(status) out += str[j+2];
      }
      if(str[j] == '<'){
	int status = 1;
	for(int k = 0; k < out.length(); k++){
	  if(out[k] == str[j+2]) status = 0;
	}
	if(status){
	  string sub;
	  sub += str[j+2];
	  sub += out;
	  out = sub;
	}
      }
    }
    cout << out << endl;
  }
  return 0;
}