#include <bits/stdc++.h>
char s[10000 + 1];
int m;
int main() {
  scanf("%s", s);
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int l, r, k, a = 0, b = 0, c = 0;
    int x = 0, y = 0, z = 0;
    char tmp[10000 + 1], tmp1[10000 + 1], tmp2[10000 + 1];
    for (int i = 0; i <= 10000; ++i) {
      tmp[i] = 0;
      tmp1[i] = 0;
      tmp2[i] = 0;
    }
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &k);
    k = k % (r - l + 1);
    while (s[a + r] != '\0') {
      tmp[a] = s[a + r];
      s[a + r] = '\0';
      a++;
    }
    while (s[b + r - k] != '\0') {
      tmp1[b] = s[b + r - k];
      s[b + r - k] = '\0';
      b++;
    }
    while (s[c + l - 1] != '\0') {
      tmp2[c] = s[c + l - 1];
      s[c + l - 1] = '\0';
      c++;
    }
    while (x != b) {
      s[x + l - 1] = tmp1[x];
      x++;
    }
    while (y != c) {
      s[y + l + k - 1] = tmp2[y];
      y++;
    }
    while (z != a) {
      s[z + r] = tmp[z];
      z++;
    }
  }
  printf("%s\n", s);
  return 0;
}
