#include <bits/stdc++.h>
using namespace std;
long long const mod = 1000000007;
long long const md = 998244353;
long long mypow(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ifstream in("txt.in");
ofstream out("txt.out");
int main() {
  cout << fixed << setprecision(12);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n;
  cin >> n;
  while (n--) {
    long long l, r, k;
    cin >> l >> r >> k;
    --l;
    --r;
    int u = r - l + 1;
    k %= u;
    char c[10005];
    int t = r - k + 1;
    for (int i = 1; i <= k; ++i) {
      c[i] = s[t];
      ++t;
    }
    t = l;
    int i = k + 1;
    while (t < r - k + 1) {
      c[i] = s[t];
      ++t;
      ++i;
    }
    t = 1;
    for (int i = l; i <= r; ++i) s[i] = c[t], ++t;
  }
  cout << s << '\n';
  return 0;
}
