#include <bits/stdc++.h>
using namespace std;
char s[10000 + 10];
char ss[10000 + 10];
int main() {
  scanf("%s", s);
  int n;
  scanf("%d", &n);
  while (n--) {
    int l, r, k, res = 0, cn = 0, cnt = 0;
    scanf("%d%d%d", &l, &r, &k);
    for (int i = l - 1; i < r; i++) ss[cnt++] = s[i];
    ss[cnt] = '\0';
    res = r - l + 1;
    cn = k % res;
    l--;
    for (int k = res - cn; k < res; k++) s[l++] = ss[k];
    for (int cn = 0, i = l; i < r; i++, cn++) s[i] = ss[cn];
  }
  printf("%s\n", s);
  return 0;
}
