#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int m;
  cin >> s;
  cin >> m;
  t = s;
  for (int o = 0; o < m; o++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    k %= (r - l + 1);
    for (int i = 0; i < r - l + 1; i++)
      t[i] = s[l + (r - l + 1 + i - k) % (r - l + 1)];
    for (int i = 0; i < r - l + 1; i++) s[l + i] = t[i];
  }
  cout << s;
  return 0;
}
