#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void printl(T a, char c = '\n') {
  cout << a << c;
}
template <typename T>
inline void print(T a, char c = ' ') {
  cout << a << c;
}
template <typename T1, typename T2>
inline void print(T1 a, T2 b) {
  cout << a << " " << b << endl;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  long long q;
  cin >> q;
  while (q--) {
    long long l, r, k;
    cin >> l >> r >> k;
    k %= (r - l + 1);
    string helper = s.substr(r - k, k);
    s.erase(s.begin() + (r - k), s.begin() + r);
    for (auto it = helper.rbegin(); it != helper.rend(); it++)
      s.insert(s.begin() + l - 1, *it);
  }
  printl(s);
  return 0;
}
