#include <bits/stdc++.h>
using namespace std;
void solve();
long long fact[200001];
long long inf = 1e18;
long long z = 1e9 + 7;
long long gdp(long long a, long long b) { return (a - (a % b)); }
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long c = power(a, b / 2, p);
  if (b % 2 == 0)
    return ((c * c) % p);
  else
    return ((((c * c) % p) * a) % p);
}
long long inverse(long long a, long long n) { return power(a, n - 2, n); }
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long ncr(long long n, long long r) {
  if (n < r || (n < 0) || (r < 0)) return 0;
  return ((((fact[n] * inverse(fact[r], z)) % z) * inverse(fact[n - r], z)) %
          z);
}
long long mods(long long n) {
  if (n > 0)
    return n;
  else
    return n * -1;
}
bool isprime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long bsv(vector<long long> arr, long long target, long long start,
              long long end) {
  int ans = -1;
  while (start <= end) {
    int mid = (start + end) / 2;
    if (arr[mid] >= target) {
      end = mid - 1;
    } else {
      ans = mid;
      start = mid + 1;
    }
  }
  return ans;
}
long long factorial(long long n) {
  return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
string str;
string solve(long long l, long long r, long long k, long long n) {
  string s1 = str.substr(0, l);
  string s2 = str.substr(r + 1, n);
  string s3 = "";
  for (long long i = r - k + 1; i <= r; i++) {
    s3 += str[i];
  }
  string s4 = "";
  for (long long i = l; i < r - k + 1; i++) {
    s4 += str[i];
  }
  return s1 + s3 + s4 + s2;
}
int main() {
  cin >> str;
  long long q;
  cin >> q;
  long long n = str.length();
  while (q--) {
    long long l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    k = k % (r - l + 1);
    str = solve(l, r, k, n);
  }
  cout << str;
}
