#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m, l, r, k;
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> l >> r >> k;
    --l;
    --r;
    string ns(r - l + 1, ' ');
    int shift = k % (r - l + 1);
    for (int j = l; j <= r; ++j) {
      if (j + shift <= r)
        ns[(j + shift) - l] = s[j];
      else
        ns[l + shift - (r - j) - 1 - l] = s[j];
    }
    s.replace(s.begin() + l, s.begin() + r + 1, ns);
  }
  cout << s << "\n";
  return 0;
}
