string s;
list<char> res;
int main() {
  boost;
  tcase {
    cin >> s;
    int n = sz(s);
    res.clear();
    list<char>::iterator it = res.begin();
    rep(i, 0, n - 1) {
      if(s[i] == '<') {
        if(it != res.begin()) {
          it--;
        }
      } else if(s[i] == '>') {
        if(it != res.end()) {
          it++;
        }
      } else if(s[i] == '-') {
        if(it != res.begin()) {
          it--;
          it = res.erase(it);
        }
      } else {
        res.insert(it, s[i]);
      }
    }
    fore(x, res) {
      cout << x;
    }
    cout << endl;
  }
  return 0;
}