#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int N = 1e3 + 2, M = 3e5 + 5, OO = 0x3f3f3f3f;
class BQueriesOnAString {
 public:
  void solve(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    int q;
    in >> q;
    string ss;
    int l, r, k;
    long long n = s.size();
    while (q--) {
      in >> l >> r >> k;
      k %= (r - l + 1);
      if (k == 0) continue;
      s = s.substr(0, l - 1) + s.substr(r - k, k) +
          s.substr(l - 1, r - k - l + 1) + s.substr(r, n - r);
    }
    out << s << '\n';
  }
};
int main() {
  BQueriesOnAString solver;
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
