#include <iostream>
#include <string>
#include <map>

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

    long long int n;
    
    std::cin >> n;

    for (; n--;) {
        std::string str, train;
        std::cin >> str;
        bool is_back = false;
        std::map<char, int> m;
        for (unsigned int i = 0; i < str.size(); i += 3) {
            if (m[str[i]]++ == 0) {
                if (is_back) {
                    train += str[i];
                }
                else {
                    train = str[i] + train;
                }
            }
            
            if (i + 1 != str.size()) {
                if (str[i + 1] == '-') {
                    is_back = true;
                }
                else {
                    is_back = false;
                }
            }
        }
        std::cout << train << std::endl;
    }

    return 0;
}