#include <bits/stdc++.h>
using namespace std;
int m;
string s, s1, s2, s3;
int l, r, k;
int main() {
  cin >> s;
  cin >> m;
  while (m--) {
    cin >> l >> r >> k;
    l--, r--;
    if (l == 0)
      s1 = "";
    else
      s1 = s.substr(0, l);
    s2 = s.substr(l, r - l + 1);
    if (r + 1 == s.size())
      s3 = "";
    else
      s3 = s.substr(r + 1, s.size() - 1 - r);
    k %= s2.size();
    s2 = s2.substr(s2.size() - k, k) + s2.substr(0, s2.size() - k);
    s = s1 + s2 + s3;
  }
  cout << s << endl;
  return 0;
}
