#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) { return !y ? x : GCD(y, x % y); }
long long LCM(long long x, long long y) { return x * y / GCD(x, y); }
string s1;
int main() {
  ios::sync_with_stdio(false);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  string s;
  cin >> s;
  int t;
  cin >> t;
  while (t--) {
    long long a, b, n;
    cin >> a >> b >> n;
    a--;
    b--;
    n %= (b - a + 1);
    string s1 = s;
    for (int f = a; f <= b; f++)
      s1[f] = s[(-n + b - a + 1 + f - a) % (b - a + 1) + a];
    s = s1;
  }
  cout << s << endl;
}
