#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("trapv")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " : " << a << endl;
  err(++it, args...);
}
long long int gcd(long long int a, long long int b) {
  while (b) {
    long long int c = b;
    b = a % b;
    a = c;
  }
  return a;
}
long long int lcm(long long int a, long long int b) {
  if (!a || !b) return 0;
  return a * b / gcd(a, b);
}
const int N = 10005;
char s[N], ot[N];
int main() {
  string loc;
  cin >> loc;
  for (long long int i = 0; i < ((loc).size()); ++i) s[i + 1] = loc[i];
  int m;
  cin >> m;
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    int len = r - l + 1;
    vector<char> v, res(len);
    for (int i = l; i <= r; i++) {
      int pos_rel = i - l + 1;
      int new_pos = (pos_rel + k) % len;
      if (new_pos == 0)
        new_pos = r;
      else
        new_pos = new_pos + l - 1;
      ot[new_pos] = s[i];
    }
    for (int i = l; i <= r; i++) s[i] = ot[i];
  }
  for (int i = 1; i <= (loc).size(); i++) cout << s[i];
  return 0;
}
