#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m, i, j, k, l, r, x, y, z, flag, count, sum, a[200005], b[200005],
      c[200005], d, mx, mn, prod;
  char s[200005], p[200005];
  scanf("%s", s);
  x = strlen(s);
  for (i = 0; i < x; i++) p[i + 1] = s[i];
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &l, &r, &k);
    y = r - l + 1;
    k %= y;
    for (j = l; j <= r; j++) {
      if (j + k > r)
        z = (j + k) % r + l - 1;
      else
        z = j + k;
      s[z] = p[j];
    }
    for (j = l; j <= r; j++) p[j] = s[j];
  }
  for (i = 1; i <= x; i++) printf("%c", p[i]);
  return 0;
}
