#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int m;
  cin >> m;
  string sub;
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    k %= (r - l + 1);
    sub = s.substr(r - k, k);
    s.erase(r - k, k);
    s.insert(l - 1, sub);
  }
  cout << s << endl;
}
