#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> A(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
		
	int q;
	cin >> q;
	
	int b, e;
	vector<int>::iterator it = A.begin();
	while (q--)
	{
		cin >> b >> e;
//		while (b < e)
//		{
//			iter_swap(it + b++, it + --e);
//		}

		//使用库函数
		reverse(A.begin()+b, A.begin()+e); 
	}
	
	while (it != A.end())
	{
		if(it != A.begin())
			cout << ' ';
		cout << *it++;
	}
	cout << endl;
	
	
	
} 



