#include <bits/stdc++.h>

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n; cin >> n;
  while(n--) {
    string s; cin >> s;
    deque<char> dq;
    set<char> st;
    dq.push_front(s[0]);
    st.insert(s[0]);
    reps(i, 3, s.size()) {
      if(!st.count(s[i])) {
	if(s[i-1] == '>') dq.push_back(s[i]);
	else dq.push_front(s[i]);
	st.insert(s[i]);
      }
      i+=2;
    }
    while(!dq.empty()) {
      cout << dq.front(); dq.pop_front();
    }
    cout << endl;
  }
  
  return 0;
}