#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, l, r, k, i;
  string s;
  cin >> s;
  cin >> n;
  while (n--) {
    cin >> l >> r >> k;
    k %= r - l + 1;
    rotate(&s[l - 1], &s[r - k], &s[r]);
  }
  cout << s;
  return 0;
}
