#include <bits/stdc++.h>
using namespace std;
inline void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const int Maxn = 200005;
int main() {
  fastIO();
  string s;
  int T, x, y, k, l, n;
  cin >> s;
  cin >> T;
  string t, temp;
  while (T--) {
    cin >> x >> y >> k;
    x--;
    y--;
    n = (y - x + 1);
    t = "";
    for (int i = x; i <= y; i++) {
      t += s[i];
    }
    k %= n;
    temp = "";
    temp += t.substr(n - k, k);
    temp += t.substr(0, n - k);
    for (int i = x; i <= y; i++) {
      s[i] = temp[i - x];
    }
  }
  cout << s << endl;
  return 0;
}
