#include <bits/stdc++.h>
std::string Rotate(std::string t, int k) {
  int n = (int)t.size();
  std::string res = t;
  for (int i = 0; i < n; ++i) {
    res[(i + k) % n] = t[i];
  }
  return res;
}
int main() {
  std::string s;
  std::cin >> s;
  int m;
  std::cin >> m;
  while (m--) {
    int l, r, k;
    std::cin >> l >> r >> k;
    --l;
    --r;
    std::string t = s.substr(l, r - l + 1);
    t = Rotate(t, k);
    for (int i = l; i <= r; ++i) {
      s[i] = t[i - l];
    }
  }
  std::cout << s << std::endl;
  return 0;
}
