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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  while(n--){
    set<char> use;
    string str;
    string ans;
    cin>>str;
    ans += str[0];
    use.insert(str[0]);
    for(int i=3;i<(int)str.size();i+=3){
      if(use.find(str[i])!=use.end()) continue;
      if(str[i-1]=='>') ans += str[i];
      else ans = str[i]+ans;
      use.insert(str[i]);
    }
    cout<<ans<<endl;
  }

  return 0;
}