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