#include <bits/stdc++.h>
using namespace std;
int len;
char s[10005], ans[10005];
int f[10005], p[10005];
int main() {
  int i, j, k, h, Q, l, r, z;
  int fj, fk, pi;
  s[0] = '$';
  while (scanf("%s", s + 1) == 1 && scanf("%d", &Q) == 1) {
    len = strlen(s);
    for (i = 0; i < len + 1; ++i) f[i] = i + 1, p[i] = i - 1;
    while (Q--) {
      scanf("%d %d %d", &l, &r, &z);
      z = z % (r + 1 - l);
      if (!z) continue;
      i = 0;
      for (h = 0; h < l; ++h) i = f[i];
      j = i;
      for (h = 0; h < r - z - l; ++h) j = f[j];
      k = j;
      for (h = 0; h < z; ++h) k = f[k];
      fj = f[j];
      fk = f[k];
      pi = p[i];
      f[pi] = fj;
      f[k] = i;
      f[j] = fk;
      p[fj] = pi;
      p[i] = k;
      p[fk] = j;
    }
    j = 0;
    for (i = 0; i < len + 1; ++i) ans[i] = s[j], j = f[j];
    printf("%s\n", ans + 1);
  }
  return 0;
}
