#include<bits/stdc++.h>
using namespace std;
string s,opt;
int n,x;
int fst;
bool rev;
void prt(){
int i=fst;
do{
cout<<s[i];
i+=(rev?-1:1);
(i+=s.size())%=s.size();
}while(i!=fst);
cout<<'\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>s>>n;
while(n--){
cin>>opt;
if(opt[0]=='r'){
fst+=(rev?1:-1);
rev^=1;
}
else{
cin>>x;
(x+=1)%=s.size();
if((opt=="<")^rev)fst-=x;
else fst+=x;
}
(fst+=s.size())%=s.size();
}
prt();
return 0;
}