#include <bits/stdc++.h>
char s[20000], aux[20000];
int main() {
  int n, t, l, r, k;
  char ch = fgetc(stdin);
  n = 0;
  while (ch != '\n') {
    s[++n] = ch;
    ch = fgetc(stdin);
  }
  fscanf(stdin, "%d", &t);
  for (; t; t--) {
    fscanf(stdin, "%d%d%d", &l, &r, &k);
    k %= (r - l + 1);
    for (int i = l; i < l + k; i++) aux[i] = s[r - k + i - l + 1];
    for (int i = l + k; i <= r; i++) aux[i] = s[i - k];
    for (int i = l; i <= r; i++) s[i] = aux[i];
  }
  for (int i = 1; i <= n; i++) fputc(s[i], stdout);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
