#include <bits/stdc++.h>
#pragma warning(disable : 4996);
const long long inf = (long long)1e18 + 111;
const int iinf = (int)1e9 + 111;
const long long mod = (long long)1e9;
using namespace std;
int main() {
  long long t, n;
  string s;
  cin >> s;
  n = s.length();
  cin >> t;
  while (t--) {
    long long l, r, k;
    cin >> l >> r >> k;
    k %= (r - l) + 1;
    rotate(&s[l - 1], &s[r - k], &s[r]);
  }
  cout << s;
}
