#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10010;
string s;
int main() {
  int m;
  cin >> s;
  cin >> m;
  int n = s.size();
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    string L = s.substr(0, l - 1);
    string R = s.substr(r, n - r);
    string M = s.substr(l - 1, r - l + 1);
    int p = k % (r - l + 1);
    string ll = M.substr(0, r - l - p + 1);
    string rr = M.substr(r - l - p + 1, p);
    s = L + rr + ll + R;
  }
  cout << s << endl;
  return 0;
}
