#include <bits/stdc++.h>
using namespace std;
long long N = 0, M, K;
long long MOD = 998244353;
string S, S1;
struct st {
  long long x, i;
};
bool operator<(const st& a, const st& b) {
  if (a.x == b.x) return a.i < b.i;
  return a.x < b.x;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long fact(long long x) {
  long long x1 = 1;
  while (x >= 1) {
    x1 *= x;
    x--;
  }
  return x1;
}
void prime(long long n, vector<long long>& pr) {
  vector<long long> lp(n + 90);
  for (long long i = 2; i <= n; ++i) {
    if (!lp[i]) {
      pr.push_back(i);
      lp[i] = i;
    }
    for (long long j = 0; j < pr.size() && pr[j] <= lp[i] && i * pr[j] <= n;
         ++j) {
      lp[i * pr[j]] = pr[j];
    }
  }
}
void dfs(long long x, vector<long long>& b, vector<long long>& w,
         vector<vector<long long>>& v) {
  w[x] = 1;
  b.push_back(x);
  for (long long i : v[x]) {
    if (!w[i]) dfs(i, b, w, v);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s, s1;
  long long n, k = 0, m;
  long long x = 0, y = 0, ans = 0;
  cin >> s >> n;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    s1 = "";
    cin >> x >> y >> k;
    m = y - x + 1;
    k = k % m;
    for (long long j = y - k; j <= y - 1; j++) s1 += s[j];
    s.erase(y - k, k);
    s.insert(x - 1, s1);
  }
  cout << s << '\n';
  cin >> N;
  return 0;
}
