#include <bits/stdc++.h>
using namespace std;
int m, len, l, r, k;
char s[10010], t[10010];
int main() {
  scanf("%s", s);
  len = strlen(s);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &l, &r, &k);
    --l, --r;
    k %= (r - l + 1);
    for (int i = l; i <= r; ++i) t[i] = s[i];
    for (int i = l, pos; i <= r; ++i) {
      pos = i - k;
      if (pos < l) pos += (r - l + 1);
      s[i] = t[pos];
    }
  }
  printf("%s\n", s);
  return 0;
}
