#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int m;
  cin >> m;
  while (m) {
    int l, r, k;
    cin >> l >> r >> k;
    --m;
    if (l == r || k == 0) continue;
    k %= (r - l + 1);
    string temp = "";
    for (int i = l - 1; i < r - k; ++i) {
      temp += s[i];
    }
    for (int i = r - 1; i >= r - k; --i) {
      temp = s[i] + temp;
    }
    for (int i = l - 1, j = 0; i < r; ++i, ++j) {
      s[i] = temp[j];
    }
  }
  cout << s << endl;
  return 0;
}
