#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  char s[10010], t[10010];
  cin >> s;
  long long int l, r, m, k;
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> l >> r, cin >> k;
    long long int len = r - l + 1, j = l - 1;
    k = k % len;
    strcpy(t, s);
    for (long long int i = l - 1; i <= r - 1 - k; i++) t[i + k] = s[i];
    for (long long int i = r - k; i <= r - 1; i++) t[j] = s[i], j++;
    strcpy(s, t);
  }
  cout << s;
  return 0;
}
