#include <bits/stdc++.h>

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int q; cin >> q;
    while (q--) {
        int l, m, r;
        cin >> l >> m >> r;
        auto b = v.begin();
        rotate(b + l, b + m, b + r);
    }
    rep(i, n) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}
