#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deq;
    int n,a,q,b1,b2,b3;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        deq.emplace_back(a);
    }
    cin >> q;
    for (int j=0;j<q;j++) {
        cin >> b1 >> b2 >> b3;
        rotate(deq.begin()+b1,deq.begin()+b2,deq.begin()+b3);
    }
    for (int k=0;k<deq.size();k++) {
        if (k==deq.size()-1) {
            cout << deq[k] << endl;
        } else {
            cout << deq[k] << " ";
        }
    }
}

