#include <bits/stdc++.h>
using namespace std;
vector<pair<char, long long>> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  v.resize(s.size(), {'0', 0});
  for (long long i = 0; i < s.size(); i++) {
    v[i].first = s[i];
    v[i].second = i + 1;
  }
  long long m;
  cin >> m;
  while (m--) {
    long long l, r, k;
    cin >> l >> r >> k;
    long long len = r - l + 1;
    for (long long i = l - 1; i < r; i++) {
      v[i].second += k - l;
      v[i].second %= len;
      v[i].second += l;
    }
    sort(v.begin(), v.end(),
         [&](pair<char, long long> &a, pair<char, long long> &b) {
           return a.second < b.second;
         });
  }
  for (long long i = 0; i < v.size(); i++) cout << v[i].first;
  cout << endl;
  return 0;
}
