#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <list>
using namespace std;

#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()

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    list<char> train;
    train.push_back(s[0]);
    int a = 0;
    for(int i=1; i<s.length();i+=3) {
      if (s[i] == '-') a++;
      else a--;
      if (a<0) {
        train.push_front(s[i+2]);
        a = 0;
      }
      if (a>=train.size())
        train.push_back(s[i+2]);
    }
    FOR(it,train)
      cout << *it;
    cout << endl;
  }
}