#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  int m;
  std::cin >> m;
  while (m--) {
    int l, r, k;
    std::cin >> l >> r >> k;
    int len = r - l + 1;
    k %= len;
    --l;
    --r;
    std::string temp = s.substr(l, len);
    int index = l + k;
    for (char ch : temp) {
      if (index > r) {
        index = l;
      }
      s[index] = ch;
      ++index;
    }
  }
  std::cout << s << std::endl;
  return 0;
}
