#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  string s;
  int n;
  while(cin>>n){
    while(n--){
      char train[52];
      for(int i=0;i<52;i++)train[i]='*';
      cin>>s;
      int pos=26;
      train[pos]=s[0];
      for(int i=3;i<s.size();i+=3){
        if(s[i-1]=='-')pos--;
        else pos++;
        train[pos]=s[i];
      }
      for(int i=0;i<52;i++){
        if(train[i]!='*'){
          while(1){
            cout<<train[i];
            i++;
            if(train[i]=='*')break;
          }
          cout<<endl;
          break;
        }
      }
    }
  }
}