#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  char bro[10005];
  int m, n, l, r, k, i, j;
  cin >> a;
  cin >> m;
  for (n = 1; n <= m; n++) {
    cin >> l >> r >> k;
    int x = 0;
    k = k % (r - l + 1);
    for (j = r - k; j < r; j++) {
      bro[x++] = a[j];
    }
    for (j = l - 1; j < r - k; j++) {
      bro[x++] = a[j];
    }
    for (j = l - 1, x = 0; j < r; j++) {
      a[j] = bro[x++];
    }
  }
  cout << a;
  return 0;
}
