#include <bits/stdc++.h>
using namespace std;
long long pow(long long m, long long n) {
  long long re = 1;
  for (long long i = 0; i < n; i++) {
    re = re * m;
  }
  return re;
}
int main() {
  char a[110000];
  gets(a);
  int l = strlen(a);
  int bal[l];
  int tal[l];
  for (int i = 0; i < l; i++) {
    tal[i] = i;
    bal[i] = i;
  }
  int q;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--;
    b--;
    int ekhn_len = b - a + 1;
    int barbe = c % ekhn_len;
    for (int i = a; i < a + barbe; i++) {
      bal[i] = bal[b - barbe + 1 + i - a];
    }
    int ii = a;
    for (int i = a + barbe; i <= b; i++) {
      bal[i] = tal[ii++];
    }
    for (int i = a; i <= b; i++) tal[i] = bal[i];
  }
  char res[11000];
  for (int i = 0; i < l; i++) {
    res[i] = a[bal[i]];
  }
  puts(res);
  return 0;
}
