#include <bits/stdc++.h>
using namespace std;
void imprimirVector(vector<long long> v) {
  if (!v.empty()) {
    int p = v.size();
    cout << "[";
    for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << ",";
    cout << v[p - 1] << "]" << endl;
  } else
    cout << "[]" << endl;
}
int toNumber(string s) {
  int Number;
  if (!(istringstream(s) >> Number)) Number = 0;
  return Number;
}
string toString(int number) {
  ostringstream ostr;
  ostr << number;
  return ostr.str();
}
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  long long m;
  cin >> m;
  for (int i = 0; i < (int)(m); i++) {
    long long l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    long long largo = k % (r - l + 1);
    string copy = s;
    for (int p = 0; p < (int)(largo); p++) s[l + p] = copy[r + p - largo + 1];
    for (int p = 0; p < (int)(r - l - largo + 1); p++)
      s[l + largo + p] = copy[l + p];
  }
  cout << s << endl;
  ;
  return 0;
}
