#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

void printvec(vi& x, int size = 0) {
    if (x.size() == 0) {
        cout << endl;
        return;
    }
    cout << x.front();
    for (int i = 1; i < (size == 0 ? x.size() : size); i++) {
        cout << " " << x[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int b, e;
        cin >> b >> e;
        reverse(as.begin() + b, as.begin() + e);
    }

    printvec(as);
}
