#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > TRI;
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &a) {
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
int main() {
  std::cout.sync_with_stdio(false);
  string s;
  int l = 0;
  int r = 4;
  int count = 4;
  int t;
  cin >> s;
  cin >> t;
  string ns = s;
  for (int k = 0; k < t; k++) {
    int l, r, count;
    cin >> l >> r >> count;
    count = count % (r - l + 1);
    if (count == 0) continue;
    for (int i = r; i >= l; i--) {
      int newPos = i + count;
      if (newPos > r) {
        newPos = l + (newPos - r) - 1;
      }
      ns[newPos - 1] = s[i - 1];
    }
    s = ns;
  }
  cout << s << endl;
  return 0;
}
