#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int dp[N][2][2];
string str;
int solve(int size, int left, int right) {
  if (size + 2 * left + 2 * right < 5) {
    return 0;
  }
  int &ret = dp[size][left][right];
  if (ret != -1) return ret;
  set<int> neighbors;
  int s = 2 * (1 - left), e = size - 1 - 2 * (1 - right);
  for (int i = s; i <= e; i++) {
    neighbors.insert(solve(i, left, 0) ^ solve(size - i - 1, 0, right));
  }
  int mex = 0;
  while (neighbors.count(mex)) {
    mex++;
  }
  return ret = mex;
}
void pushAllWinningMoves(int ss, int ee, int left, int right, int target,
                         vector<int> &idx) {
  int size = ee - ss;
  int s = 2 * (1 - left), e = size - 1 - 2 * (1 - right);
  for (int i = s; i <= e; i++) {
    if ((solve(i, left, 0) ^ solve(size - i - 1, 0, right)) == target) {
      idx.push_back(ss + i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  string x;
  int q, l, r, k;
  cin >> q;
  while (q--) {
    cin >> l >> r >> k;
    x = s;
    l--, r--;
    int size = r - l + 1;
    k %= size;
    for (int i = 0; i < size; i++) {
      x[l + i] = s[((i - k) + size) % size + l];
    }
    s = x;
  }
  cout << s << endl;
  return 0;
}
