#include <bits/stdc++.h>
using namespace std;
char s[10000];
char sc[10000];
int main() {
  int i, j, m, l, r, k;
  cin >> s + 1;
  cin >> m;
  while (m) {
    cin >> l >> r >> k;
    k %= (r - l + 1);
    j = 1;
    for (i = r - k + 1; i <= r; i++) {
      if (s[i] != 0) {
        sc[j] = s[i];
        j++;
      }
    }
    for (i = l; i <= r - k; i++) {
      sc[j] = s[i];
      j++;
    }
    j = 1;
    for (i = l; i <= r; i++) {
      s[i] = sc[j];
      j++;
    }
    m--;
  }
  cout << s + 1;
}
