#include <bits/stdc++.h>
using namespace std;
const int N = 1e9;
int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  while (q--) {
    int l, r, k;
    cin >> l >> r >> k;
    string s1 = s;
    int L = r - l + 1;
    k = k % L;
    for (int i = l; i <= r; i++) {
      if (i + k <= r) {
        s[i + k - 1] = s1[i - 1];
      } else {
        int z = (i + k) - r;
        s[l + z - 1 - 1] = s1[i - 1];
      }
    }
  }
  cout << s;
}
