#include <bits/stdc++.h>
using namespace std;
long long i, j, m, n, l, r, k, len;
string s, tem;
int main() {
  cin >> s;
  n = s.size();
  scanf("%I64d", &m);
  for (i = 0; i < m; ++i) {
    scanf("%I64d%I64d%I64d", &l, &r, &k);
    tem = s;
    l--;
    r--;
    len = r - l + 1;
    k %= len;
    for (j = l; j < l + k; ++j) {
      tem[j] = s[r - k + j - l + 1];
    }
    for (j = l + k; j <= r; ++j) {
      tem[j] = s[j - k];
    }
    s = tem;
  }
  cout << s << endl;
  return 0;
}
