#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
bool isPrime(long long x) {
  for (long long d = 2; d * d <= x; d++) {
    if (x % d == 0) return false;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    char s[10002];
    string temp;
    cin >> temp;
    long long i = 0;
    for (char x : temp) {
      s[i] = x;
      i++;
    }
    long long n = temp.length();
    long long m;
    cin >> m;
    while (m--) {
      long long l, r, k;
      cin >> l >> r >> k;
      long long len = r - l + 1;
      k = k % len;
      l--;
      r--;
      reverse(s + l, s + l + len - k);
      reverse(s + l + len - k, s + l + len);
      reverse(s + l, s + l + len);
    }
    for (long long i = 0; i < n; i++) {
      cout << s[i];
    }
  }
  cin.clear();
  cin.get();
  return 0;
}
