#include<bits/stdc++.h>
using namespace std;
#define neverTLE ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define reg register
string s;
int m;
struct node{
char ch;
node *next,*last;
};
node *head=nullptr;
int main(){
cin>>s;
node *curr=new node;
curr->next=head;
curr->last=NULL;
head=new node;
head->last=curr;
head->ch=s[0];
head->next=NULL;
node* now=head;
for(int i=1;i<s.size();i++){
node *cur=now;
now=new node;
now->last=cur;
cur->next=now;
now->next=NULL;
now->ch=s[i];
}
cin>>m;
int l,r,k;
for(reg int i=1;i<=m;i++){
cin>>l>>r>>k;
node *ll,*rr;
node *nowwww=head;
for(int j=1;j<=r;j++){
if(j==l) ll=nowwww;
if(j==r) rr=nowwww;
nowwww=nowwww->next;
}
for(reg int j=1;j<=k;j++){
node *nn=new node;
nn->ch=rr->ch;
ll->last->next=nn;
nn->last=ll->last;
nn->next=ll;
ll->last=nn;
ll=nn;
if(l==1){
head=ll;
delete curr;
curr=new node;
curr->last=NULL;
curr->next=head;
head->last=curr;
}
rr->last->next=rr->next;
rr->next->last=rr->last;
node *lll=rr->last;
delete rr;
rr=lll;
}
}
while(head!=NULL){
cout<<head->ch;
head=head->next;
}
return 0;
}