#include<iostream>
using namespace std;

int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      string s;
      cin>>s;
      string ans="";
      ans+=s[0];
      int now=0;
      if(s.size()>2 && s[1]=='-')
	now++;
      else
	now--;
      for(int i=3;i<s.size();i+=3)
	{	  
	  if(now<0)
	    {
	      ans=s[i]+ans;
	      now++;
	    }
	  else if(now>=ans.size())
	    {
	      ans+=s[i];	     
	    }
	  
	  if(i+1<s.size()-1)
	    {
	      if(s[i+1]=='-')
		now++;
	      else
		now--;
	    }
	}
      cout<<ans<<endl;
      
    }
}