#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;
int a[MAX], b[MAX];
int n, m, nQ, lo, hi;
pair<int, int> q[MAX];
pair<int, int> x;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> x.first >> x.second;
    while (nQ && q[nQ - 1].second <= x.second) nQ--;
    q[nQ++] = x;
  }
  q[nQ++] = make_pair(0, 0);
  lo = 0, hi = q[0].second;
  for (int i = 0; i < hi; i++) b[i] = a[i], a[i] = -1;
  sort(b, b + hi);
  for (int i = 1; i < nQ; i++) {
    if (q[i - 1].first == 1)
      for (int j = q[i - 1].second; j > q[i].second; j--) a[j - 1] = b[--hi];
    else
      for (int j = q[i - 1].second; j > q[i].second; j--) a[j - 1] = b[lo++];
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
