#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int num[maxn], ans[maxn], themax[maxn];
pair<int, int> pa[maxn];
int main() {
  int n, m, fla = 1;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  for (int i = 1; i <= m; i++) scanf("%d %d", &pa[i].first, &pa[i].second);
  pa[m + 1].first = 1, pa[m + 1].second = 0;
  for (int i = m + 1; i >= 1; i--) themax[i] = max(themax[i + 1], pa[i].second);
  for (int i = 1; i <= m + 1; i++) {
    if (themax[i] == pa[i].second) {
      sort(num + 1, num + 1 + pa[i].second);
      break;
    }
  }
  int a = 1, b = n, d = n;
  for (int i = 1; i <= m + 1; i++) {
    if (themax[i] != pa[i].second) continue;
    if (fla == 1) {
      while (d > pa[i].second) {
        ans[d] = num[b];
        d--, b--;
      }
    } else {
      while (d > pa[i].second) {
        ans[d] = num[a];
        d--, a++;
      }
    }
    fla = pa[i].first;
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
