#include <bits/stdc++.h>
using namespace std;
char s[10001], sr[10001];
struct vv {
  unsigned int l, r, k;
};
vv v[300];
int main(int argc, char* argv[]) {
  unsigned int m;
  cin >> s >> m;
  for (unsigned int i = 0; i < m; ++i) {
    cin >> v[i].l >> v[i].r >> v[i].k;
    --v[i].l;
    v[i].k %= v[i].r - v[i].l;
  }
  for (unsigned int i = 0; s[i]; ++i) {
    unsigned int ix = i;
    for (unsigned int j = 0; j < m; ++j) {
      if (ix >= v[j].l && ix < v[j].r) {
        ix += v[j].k;
        if (ix >= v[j].r) ix -= v[j].r - v[j].l;
      }
    }
    sr[ix] = s[i];
  }
  cout << sr << endl;
  return 0;
}
