#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n; cin >> n;
  while(n --> 0){
    string ans;
    int apos = 0;
    int pos = 0;
    string str;
    cin >> str;
    ans = str[0];
    pos+=2;
    while(pos < str.size()){
      //printf("str[pos]=%c\n",str[pos]);
      if(str[pos] == '-'){
        apos--;
      }else{
        apos++;
      }
      pos++;
      //printf("%s (apos = %d)\n",ans.c_str(),apos);
      if(apos == -1){
        apos = 0;
        ans = str[pos] + ans;
      }else if(apos == ans.size()){
        ans = ans + str[pos];
      }else{
      }
      pos += 2;
    }
    cout << ans << endl;
  }
  return 0;
}