#include <bits/stdc++.h>
using namespace std;
char str[10010];
char temp1[10010];
char temp2[10010];
int main() {
  scanf("%s", str);
  int t;
  cin >> t;
  while (t--) {
    memset(temp1, 0, sizeof(temp1));
    memset(temp2, 0, sizeof(temp2));
    int x, y;
    int k;
    scanf("%d%d%d", &x, &y, &k);
    int len = k % (y - x + 1);
    strncpy(temp1, str + x - 1, y - x + 1 - len);
    strncpy(temp2, str + x - 1 + y - x + 1 - len, len);
    strncpy(str + x - 1, temp2, len);
    strncpy(str + x - 1 + len, temp1, y - x + 1 - len);
  }
  cout << str << endl;
  return 0;
}
