#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 2e6 + 7, M = 2e6 + 7, INF = INT_MAX / 10;
unsigned powe(unsigned x, unsigned y) {
  x = x, y = y;
  unsigned ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans);
    }
    y >>= 1;
    x = (1ll * x * x);
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  string s;
  cin >> s;
  long long n;
  cin >> n;
  while (n--) {
    long long l, r, k, i, j;
    cin >> l >> r >> k;
    string a = s.substr(l - 1, r - 1);
    for (i = l - 1; i < r; i++) {
      a[(i - l + 1 + k) % (r - l + 1)] = s[i];
    }
    for (i = l - 1; i < r; i++) s[i] = a[i - l + 1];
  }
  cout << s << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
