#include <bits/stdc++.h>
using namespace std;
int dr[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
const int MAX = 100000 + 7;
vector<string> ans;
int sum[MAX];
int main() {
  string s;
  cin >> s;
  long long m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    long long l, r, k;
    cin >> l >> r >> k;
    string tmp = s;
    for (int j = 0; j < r - l + 1; ++j)
      s[j + l - 1] =
          tmp[((j - k) + 10000007 * (r - l + 1)) % (r - l + 1) + l - 1];
  }
  cout << s << "\n";
}
