#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, q, l, r, a[105] = {};
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
cin >> q;
while (q--)
{
cin >> l >> r;
sort(a + l, a + r + 1);
}
for (int i = 1; i <= n; i++)
cout << a[i] << " ";
return 0;
}