#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1;
  cin >> s1;
  int t;
  cin >> t;
  while (t--) {
    int l, r, k;
    cin >> l >> r >> k;
    k = k % (r - l + 1);
    string temp = s1.substr(0, l - 1) + s1.substr(r - k, k) +
                  s1.substr(l - 1, r - l - k + 1) + s1.substr(r);
    s1 = temp;
  }
  cout << s1;
}
