#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  int T;
  string record;
  cin >> T;
  while(T--){
    cin >> record;
    map<int, char> train;
    int now = 0;
    for(int i = 0 ; i < record.size(); i+=3){
      train[now] = record[i];
      if(record[i+1] == '<') now--;
      else now++;
    }
    
    for(map<int, char>::iterator it = train.begin() ; it != train.end() ; it++){
      cout << it->first  << it->second << ' ';
    }
    cout << endl;
  }
}