#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
char s[N];
char t[N];
int n, m;
int main() {
  scanf("%s", s + 1);
  n = strlen(s);
  scanf("%d", &m);
  while (m--) {
    int l, r, k;
    scanf("%d%d%d", &l, &r, &k);
    k %= (r - l + 1);
    for (int i = 0; i < k; i++) {
      t[l + i] = s[r - k + 1 + i];
    }
    for (int i = k; i <= r - l; i++) t[l + i] = s[l - k + i];
    for (int i = l; i <= r; i++) s[i] = t[i];
  }
  printf("%s\n", s + 1);
  return 0;
}
