#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long int m;
  cin >> m;
  while (m--) {
    long long int l, r, k;
    cin >> l >> r >> k;
    long long int siz = r - l + 1;
    k %= (siz);
    if (k != 0) {
      l--;
      r--;
      long long int ta = siz - k;
      reverse(s.begin() + l, s.begin() + (l + ta));
      reverse(s.begin() + (l + ta), s.begin() + (r + 1));
      reverse(s.begin() + (l), s.begin() + (r + 1));
    }
  }
  cout << s;
  return 0;
}
