#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n;
    string str;
    char t[100];

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> str;

        for( int j = 0; j < 100; j++ )
            t[j] = '0';        

        int k = 50;
        for( int j = 0; j < str.size(); j++ )
        {
            if( t[k] != str[j] )
                t[k] = str[j];

            if( j + 1 < str.size() && str[j+1] == '-' )
                k++;
            else if( j + 1 < str.size() )
                k--;
            else;

            j += 2;
        }
            
        for( int j = 0; j < 100; j++ )
            if( t[j] != '0' )
                cout << t[j];
        cout << endl;
    }


    return 0;
}

