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