#include <bits/stdc++.h>
using namespace std;
int l, r, k, m;
string s, a;
string qoas() {
  int c = l;
  a = s;
  for (int i = r + 1 - k; i <= r; ++i) a[c++] = s[i];
  for (int i = l; i <= r - k; ++i) a[c++] = s[i];
  return a;
}
int main() {
  cin >> s >> m;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> k;
    k = k % (r - l + 1);
    --l, --r;
    s = qoas();
  }
  cout << s;
  return 0;
}
