#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char sdigits[s.size()];
  for (int i = 0; i < s.size(); i++) sdigits[i] = s[i];
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    long long l, r, k;
    cin >> l >> r >> k;
    l -= 1;
    long long move = k % (r - l);
    char change[r - l];
    for (int i = l; i < r; i++) {
      change[i - l] = sdigits[i];
    }
    long long lvar = l;
    for (int i = (r - l) - move; i < (r - l); i++) {
      sdigits[lvar] = change[i];
      lvar += 1;
    }
    for (int i = 0; i < (r - l) - move; i++) {
      sdigits[lvar] = change[i];
      lvar += 1;
    }
  }
  for (auto x : sdigits) cout << x;
  cout << endl;
}
