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