#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b, m, e;
        cin >> b >> m >> e;
        int k;
        k = e - b;
        if(k == 0) {}
        else k--;
        int p;
        p = b + ((k+(e-m)) % (e-b));
        rotate(v.begin()+b, v.begin()+m, v.begin()+e);
    }

    for(int i = 0; i < v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}
