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