#include <bits/stdc++.h>
using namespace std;
int a, x, y, z, c, s = 1, e, m;
string v, d;
int main() {
  cin >> v;
  d = v;
  scanf("%d", &a);
  for (int i = 0; i < a; i++) {
    scanf("%d%d%d", &x, &y, &z);
    e = y - (x - 1);
    for (int j = 1, i = x; j <= e; i++, j++) {
      c = (j + z) % e;
      if (c == 0) c = e;
      d[x + (c - 2)] = v[i - 1];
    }
    v = d;
  }
  cout << d << endl;
}
