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

int main()
{
    vector<int> v;
    int n;
    cin >> n;

    while (n--)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }

    int q;
    cin >> q;

    while (q--)
    {
        int a, b;
        cin >> a >> b;
        reverse(v.begin() + a, v.begin() + b);
    }

    for (n = 0; n < v.size(); n++)
    {
        if (n)
            cout << " ";
        cout << v[n];
    }
    cout << endl ;
}
