#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll Q;
    cin >> Q;

    while(Q--){
        ll b, m, e;
        cin >> b >> m >> e;

        auto it = A.begin();
        rotate(it+b, it+m, it+e);
    }

    FOR(i, 0, N){
        if(i){
            cout << ' ';
        }
        cout << A[i];
    }
    cout << endl;

    return 0;
}
