#include <bits/stdc++.h>
using namespace std;
void func(int l, int r, int k, char* s) {
  l--;
  r--;
  int len = r - l + 1;
  int move = k % len;
  if (move) {
    char temp[10000];
    for (int i = 0; i < move; ++i) temp[i] = s[r - move + i + 1];
    for (int i = 0; i < len - move; i++)
      s[l + len - i - 1] = s[l + len - move - i - 1];
    for (int i = 0; i < move; ++i) s[l + i] = temp[i];
  }
}
int main() {
  char s[10000];
  cin >> s;
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int l, r, k;
    cin >> l >> r >> k;
    func(l, r, k, s);
  }
  cout << s << endl;
  return 0;
}
