#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m = 0;
  cin >> m;
  int l = 0, r = 0, k = 0;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> k;
    l--;
    r--;
    int len = r - l + 1;
    string copy = s.substr(l, len);
    k = k % len;
    string paste = copy;
    for (int j = 0; j < copy.size(); j++) {
      int toPasteIndex = (j + k) % len;
      paste[toPasteIndex] = copy[j];
    }
    for (int j1 = l, j2 = 0; j1 <= r && j2 < paste.size(); j1++, j2++) {
      s[j1] = paste[j2];
    }
  }
  cout << s << endl;
  return 0;
}
