#include <bits/stdc++.h>
using namespace std;
int n, q, k, mod, l, r, f;
string s;
char temp;
vector<char> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> q;
  while (q--) {
    cin >> l >> r >> k;
    l--, r--;
    mod = k % (r - l + 1);
    f = r;
    while (mod--) {
      v.push_back(s[f]), f--;
    }
    for (int i = r; i > l; i--) {
      s[i] = s[f];
      f--;
    }
    n = v.size();
    while (n--) {
      s[l] = v.back();
      l++;
      v.pop_back();
    }
  }
  cout << s << endl;
  return 0;
}
