#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int t;
  char arr[10002];
  cin >> t;
  while (t--) {
    int m, r, k;
    cin >> m >> r >> k;
    k = k % (r - m + 1);
    int c = k;
    m--;
    int e = m;
    for (int i = r - k; k--; i++) {
      arr[e] = s[i];
      e++;
    }
    for (int i = m; i < r - c; i++) {
      arr[e] = s[i];
      e++;
    }
    for (int i = m; i < r; i++) s[i] = arr[i];
  }
  cout << s << "\n";
  return 0;
}
