#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double PI = 3.14159265358979323846;
int main() {
  if (1) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  string s, t;
  cin >> s;
  t = s;
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int l, r, k;
    cin >> l >> r >> k;
    k %= r - l + 1;
    for (int j = l - 1; j < r; ++j) {
      int ni = j - k;
      if (ni < l - 1) ni += r - l + 1;
      s[j] = t[ni];
    }
    t = s;
  }
  cout << s << endl;
  return 0;
}
