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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    rep(I, n){
        string s;
        cin >> s;

        deque<char> ans;
        vector<bool> used(26);
        ans.push_back(s[0]);
        used[s[0] - 'a'] = true;

        for(int i = 3, i_len = s.size() ; i < i_len ; i += 3){
            if(!used[s[i] - 'a']){
                used[s[i] - 'a'] = true;
                if(s[i - 1] == '>'){
                    ans.push_back(s[i]);
                }else{
                    ans.push_front(s[i]);
                }
            }
        }

        rep(i, ans.size()){
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}
