#include <bits/stdc++.h>
using namespace std;
int a, g, d;
int main() {
  char s[10000];
  cin >> s;
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> g >> d;
    int l = g - a + 1;
    a = a - 1;
    g = g - 1;
    rotate(s + a, s + (g - (d % l) + 1), s + g + 1);
  }
  cout << s;
  return 0;
}
