#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int N = 1e4 + 11;
char a[N], b[N];
int m, L, R, k;
int main() {
  scanf("%s", a + 1);
  a[0] = 'p';
  int len = strlen(a);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &L, &R, &k);
    k = k % (R - L + 1);
    for (int i = L; i <= R; i++) {
      if (i + k <= R)
        b[i + k] = a[i];
      else
        b[L + k - (R - i) - 1] = a[i];
    }
    for (int i = L; i <= R; i++) {
      a[i] = b[i];
    }
  }
  for (int i = 1; i <= len; i++) {
    b[i - 1] = a[i];
  }
  b[len] = '\0';
  cout << b << endl;
  return 0;
}
