#include <bits/stdc++.h>
using namespace std;
string s, ans;
int a[10010], m, l[301], r[301], k[300], n;
int main() {
  cin >> s;
  n = s.length();
  s = " " + s;
  ans = s;
  for (int i = 1; i <= n; ++i) a[i] = i;
  cin >> m;
  for (int i = 1; i <= m; ++i) cin >> l[i] >> r[i] >> k[i];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i] >= l[j] && a[i] <= r[j]) {
        k[j] %= (r[j] - l[j] + 1);
        a[i] += k[j];
        if (a[i] > r[j]) a[i] = l[j] + (a[i] - r[j]) - 1;
      }
  for (int i = 1; i <= n; ++i) ans[a[i]] = s[i];
  ans.erase(0, 1);
  cout << ans;
  return 0;
}
