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