#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int m;
  cin >> s >> m;
  for (int i = 0; i < m; i++) {
    int l, r, k;
    scanf("%d%d%d", &l, &r, &k);
    l--;
    k %= (r - l);
    if (k == 0) continue;
    string c = s.substr(l, (r - l));
    for (int j = l; j < l + k; j++) s[j] = c[r - k + j - 2 * l];
    for (int j = l + k; j < r; j++) s[j] = c[j - l - k];
  }
  cout << s << endl;
}
