#include <bits/stdc++.h>
using namespace std;
void shift(string& s, int l, int r, int k) {
  string new_s;
  for (int i = r - k + 1; i <= r; i++) new_s.push_back(s[i]);
  for (int i = l; i < r - k + 1; i++) new_s.push_back(s[i]);
  for (int i = l; i <= r; i++) s[i] = new_s[i - l];
}
int main() {
  int T;
  T = 1;
  while (T--) {
    string s;
    cin >> s;
    int m;
    cin >> m;
    while (m--) {
      int l, r, k;
      cin >> l >> r >> k;
      shift(s, l - 1, r - 1, k % (r - l + 1));
    }
    cout << s << "\n";
  }
}
