#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int n = str.size();
  int m;
  cin >> m;
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    int pp = r - l + 1;
    k = k % pp;
    string str2;
    str2 = str;
    int hh = 0;
    for (int i = l; i <= r; i++) {
      int j = l + (hh + k) % pp;
      hh++;
      str2[j] = str[i];
    }
    str = str2;
  }
  cout << str;
}
