#include <bits/stdc++.h>
using namespace std;

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

//////////////////////////////////////////////////////////////


int main() {
  
  int Tc; cin >> Tc;
  while(Tc --) {
    list<char> lst;
    
    string s; cin >> s;
    int const N = s.size();
    
    lst.push_back(s[0]);
    for(int i=3; i<N; i+=3) {
      if(s[i-1] == '>') {
	list<char>::iterator it = find(ALL(lst), s[i-3]);
	advance(it, 1);
	if(s[i] != *it) lst.insert(it, s[i]);
      }
      else {
	list<char>::iterator it = find(ALL(lst), s[i-3]);
	if(it != lst.begin()) advance(it, -1);
	if(s[i] != *it) lst.insert(it, s[i]);
      }
    }

    EACH(it, lst) {cout << *it;}cout << endl;
  }
  
  return 0;
}