#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int m;
  cin >> s >> m;
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    int init = l - 1;
    int len = r - l + 1;
    string ns = s;
    for (int i = init; i < r; i++) {
      int pos = init + (i - init + k) % len;
      ns[pos] = s[i];
    }
    s = ns;
  }
  cout << s << endl;
}
