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