#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238L;
int fac[2000005] = {0};
void factorial() {
  fac[0] = 1;
  fac[1] = 1;
  for (int i = 2; i < 200005; i++)
    fac[i] = ((i % 1000000007) * (fac[i - 1] % 1000000007)) % 1000000007;
}
int power(int n, int m) {
  int p = 1;
  if (m == 0) return 1;
  p = (power(n, m / 2) % 1000000007);
  p = (p % 1000000007 * p % 1000000007) % 1000000007;
  return (m & 1 ? ((p % 1000000007 * n % 1000000007) % 1000000007)
                : (p % 1000000007));
}
int ncr(int n, int r) {
  return ((fac[n] * power(fac[r], 1000000007 - 2)) % 1000000007 *
          power(fac[n - r], 1000000007 - 2)) %
         1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string second;
  cin >> second;
  int n;
  cin >> n;
  while (n--) {
    int l, r, k;
    string change;
    cin >> l >> r >> k;
    k = k % (r - l + 1);
    if (k != 0) {
      int start = r - k + 1;
      start--;
      for (int j = start; j < r; j++) change.push_back(second[j]);
      for (int j = l - 1; j < start; j++) change.push_back(second[j]);
      long long index = 0;
      for (int j = l - 1; j < r; j++) {
        second[j] = change[index];
        index++;
      }
    }
  }
  cout << second << "\n";
  return 0;
}
