#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
template <typename T>
inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T>
inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (ll i = (0); i < (n); i++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--, r--;
    string t;
    for (ll j = (0); j < (r - l + 1); j++)
      t += s[l + (j + (r - l + 1) - k % (r - l + 1)) % (r - l + 1)];
    s = s.substr(0, l) + t + s.substr(r + 1);
  }
  cout << s << endl;
  return 0;
}
