#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string z = s;
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    k %= (r - l + 1);
    if (k != 0) {
      for (int j = l + k; j <= r; j++) s[j] = z[j - k];
      int t = 0;
      for (int j = l; j < l + k; j++) {
        s[j] = z[r - k + 1 + t];
        t++;
      }
    }
  }
  cout << s << endl;
  return 0;
}
