#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string S;
int n;
cin >> S;
cin >> n;
string op;
int x;
int cnt=0;
bool f=0;
for (int i = 0; i < n; ++i) {
cin >> op;
if (op == "rev") {
f=!f;
} else {
cin >> x;
x%=S.size();
if (op[0] == '<') {
if(f==1) cnt-=x;
else cnt+=x;
} else if (op[0] == '>') {
if(f==1) cnt+=x;
else cnt-=x;
}
}
}
cnt=cnt%(S.size());
if(f) reverse(S.begin(),S.end());
string s=S;s+=s;
cout<<s.substr(cnt,S.size());
return 0;
}