#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, l, r, k;
  string s, s1, s2;
  cin >> s;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> k;
    k = k % (r - l + 1);
    s1 = s.substr(r - k, k);
    s2 = s.substr(l - 1, r - l + 1 - k);
    s1 = s1 + s2;
    for (int j = 0; j < s1.size(); ++j) {
      s[l - 1 + j] = s1[j];
    }
  }
  cout << s;
  return 0;
}
