#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
const long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int Q;
  cin >> Q;
  while (Q--) {
    int l, r, k;
    cin >> l >> r >> k;
    l--, r--;
    k %= (r - l + 1);
    string to = s.substr(l, r - l + 1);
    for (__typeof(r + 1) i = (l) - ((l) > (r + 1));
         i != (r + 1) - ((l) > (r + 1)); i += ((l) > (r + 1) ? -1 : 1)) {
      to[(i - l + k) % to.size()] = s[i];
    }
    s = s.substr(0, l) + to + s.substr(r + 1);
  }
  cout << s << '\n';
  return 0;
}
