#include <bits/stdc++.h>
using namespace std;
string s;
void perform(int l, int r, int k) {
  string sub = s.substr(l, r - l + 1);
  int len = sub.size();
  for (int i = 0; i < len; ++i) {
    int d = len - k;
    while (d < 0) {
      d += len;
    }
    s[i + l] = sub[(i + d) % len];
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> s;
  cin >> m;
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    perform(l - 1, r - 1, k);
  }
  cout << s << endl;
  return 0;
}
