#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m;
  cin >> m;
  int l, r, k, pos;
  while (m--) {
    cin >> l >> r >> k;
    pos = k % (r - l + 1);
    rotate(s.begin() + l - 1, s.begin() + r - pos, s.begin() + r);
  }
  cout << s << endl;
  return 0;
}
