#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char s[10001];
  int n;
  cin >> s;
  cin >> n;
  reverse(s, s + strlen(s));
  while (n--) {
    int a, b, c;
    cin >> a >> b >> c;
    a = strlen(s) - a;
    b = strlen(s) - b;
    swap(a, b);
    c = c % (b - a + 1);
    rotate(s + a, s + a + c, s + b + 1);
  }
  reverse(s, s + strlen(s));
  cout << s;
  return 0;
}
