//***************************************\\
//********Author -- Raju Varshney********\\
//***************************************\\
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#include<utility>
#include<algorithm> //min,max,swap(a,b),sort
#include<list>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<iostream>
#include<deque>
#include<string>
using namespace std;
#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define sz(a) int((a).size())
#define pb push_back
#define mpa make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define abs(x) ((x)>0?(x):-(x))
#define si(i) scanf("%d",&i)
#define sl(i) scanf("%I64d",&i)
#define sf(i) scanf("%f",&i)
#define ss(i) cin>>i
#define pi(i) printf("%d ",i)
#define pni(i) printf("%d \n",i)
#define pl(i) printf("%I64d ",i)
#define pnl(i) printf("%I64d \n",i)
#define pf(i) printf("%f ",i)
#define pnf(i) printf("%f \n",i)
#define ps(i) cout<<i
#define pns(i) cout<<i<<'\n'
#define gcd(a,b) std::__gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define lcm1(a,b) (a*b)/gcd1(a,b)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define lb(v,x) lower_bound(v.begin(), v.end(), x)-v.begin() // frst element jst >=
#define ub(v,x) upper_bound(v.begin(), v.end(), x)-v.begin() // frst element jst >
#define strlower(a) transform(a.begin(), a.end(), a.begin(), ::tolower)
#define strupper(a) transform(a.begin(), a.end(), a.begin(), ::toupper)
#define pfloat(a,b) cout<<setprecision(b)<<fixed<<a<<' '
#define pnfloat(a,b) cout<<setprecision(b)<<fixed<<a<<'\n'
#define starttime clock_t t1time;t1time=clock()
#define stoptime t1time=clock()-t1time;double time_taken=((double)t1time)/CLOCKS_PER_SEC;printf("program take %f seconds to execute \n", time_taken)
#define MOD 1000000007
//Remember that set and map have the member functions find() and count(), which works in O(log N), while std::find() and std::count() take O(N).
/*
ll gcd1(ll a , ll b)
{
if(b==0) return a;
a%=b;
return gcd(b,a);
}
int add(int a, int b) {
a += b;
if (a >= MOD) a -= MOD;
return a;
}
int sub(int a, int b) {
a -= b;
if ( a < 0 ) a += MOD;
return a;
}
int mul(int a, int b) {
return ((long long)a) * b % MOD;
}
int expmod(int a, int b) {
long long x = 1, y = a;
while(b) {
if (b & 1) x = mul(x, y);
y = mul(y, y);
b >>= 1;
}
return x;
}
*/
// itoa(num, str, base); str must be in form char str[n];
/*
typedef struct point{
int x, y;
}point;
bool cmp(point a, point b) {
if(a.x==b.x)
return a.y<b.y;
return a.x < b.x;
}
sort(a,a+n,cmp);
*/
//vi v1(size,-1);
//vvi v2 (size1, v1);
//vector<pair<pii,int> >E;
//E.pb(mpa(mpa(u,v),x));
int main(){
// freopen("a.txt","r",stdin);
// freopen("bb.txt","w",stdout);
// clock_t t1;
// t1=clock();
int t;si(t);
string s;
loop(ii,0,t){
ss(s);
list<char> my;
list<char>:: iterator it;
list<char>:: iterator jj;
it=my.begin();
loop(j,0,s.length()){
if(s[j]=='<'){
if(sz(my)!=0)
it--;
}
else if(s[j]=='>'){
//cout << *it<<" "<<*--my.end()<<endl;
if(--my.end()!=it)
it++;
}
else if(s[j]=='-'){
if(sz(my)!=0){
jj=--it;
my.erase(++it);
it=jj;
}
}
else{
if(sz(my)==0){
my.pb(s[j]);
it++;
}
else{
jj=it;
my.insert(++jj,s[j]);
it++;
}
}
}
tr(my,ll)
cout << *ll;
cout <<endl;
}
// t1 = clock() - t1;
// double time_taken = ((double)t1)/CLOCKS_PER_SEC; // in seconds
// printf("program take %f seconds to execute \n", time_taken);
return 0;
}
Ly8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipcXAovLyoqKioqKioqQXV0aG9yIC0tIFJhanUgVmFyc2huZXkqKioqKioqKlxcCi8vKioq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