#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long len = s.length();
  char ar[len + 1];
  for (long long i = 0; i < len; i++) ar[i + 1] = s[i];
  long long t;
  cin >> t;
  while (t--) {
    long long l, r, k;
    cin >> l >> r >> k;
    long long temp = r - l + 1;
    long long k1 = k % temp;
    char br[temp + 1];
    for (long long i = l; i <= r; i++) {
      long long index = i - l;
      br[(index + k1) % temp + 1] = ar[i];
    }
    long long j = 1;
    for (long long i = l; i <= r; i++) {
      ar[i] = br[j];
      j++;
    }
  }
  for (long long i = 1; i <= len; i++) cout << ar[i];
  cout << "\n";
}
