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