#include <bits/stdc++.h>
using namespace std;
string s;
int m, l[400], r[400], k[400];
char q[11000];
int main() {
  cin >> s;
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> l[i] >> r[i] >> k[i];
    for (int j = l[i] - 1; j <= r[i] - 1; ++j) {
      q[j] = s[j];
    }
    for (int j = l[i] - 1; j <= r[i] - 1; ++j) {
      int y;
      y = k[i] % (r[i] - l[i] + 1);
      if (j - l[i] + 1 >= y)
        s[j] = q[j - y];
      else
        s[j] = q[j - y + r[i] - l[i] + 1];
    }
  }
  cout << s;
  return 0;
}
