#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int m;
  cin >> m;
  while (m > 0) {
    long l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    string tempstr = str;
    long ln = k % (r - l + 1) + l;
    long diff = ln - l;
    long i;
    for (i = 0; i < r - l + 1; i++) {
      str[l + (i + diff) % (r - l + 1)] = tempstr[l + i];
    }
    m--;
  }
  cout << str << endl;
  return 0;
}
