#include <bits/stdc++.h>
using namespace std;
const int M = 200010;
int A[M];
pair<int, int> f[M];
vector<pair<int, int> > q;
multiset<int> S;
int ans[M];
int main() {
  int i, j, k, n, temp, cur, qr;
  scanf("%d%d", &n, &qr);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  for (i = 0; i < qr; i++) {
    scanf("%d%d", &j, &k);
    f[i] = make_pair(j, k);
  }
  int maxx = 0;
  q.push_back(make_pair(1, 0));
  for (i = qr - 1; i >= 0; i--) {
    if (f[i].second > maxx) {
      q.push_back(f[i]);
      maxx = f[i].second;
    }
  }
  multiset<int>::iterator it;
  for (i = q[q.size() - 1].second; i < n; i++) ans[i] = A[i];
  for (i = q[q.size() - 1].second - 1; i >= 0; i--) S.insert(A[i]);
  for (i = q.size() - 2; i >= 0; i--) {
    int first = q[i + 1].first, last = q[i + 1].second;
    if (first == 1) {
      for (j = last - 1; j >= q[i].second; j--) {
        it = S.end();
        it--;
        ans[j] = *it;
        S.erase(it);
      }
    } else {
      for (j = last - 1; j >= q[i].second; j--) {
        it = S.begin();
        ans[j] = *it;
        S.erase(it);
      }
    }
  }
  for (i = 0; i < n; i++) printf("%d ", ans[i]);
  printf("\n");
  ;
  return 0;
}
