#include <bits/stdc++.h>
using namespace std;
int n, m, v[200005], t, sor[200005], poz[200005], maxr, lastp, tt, r;
deque<int> dq;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 1; i <= m; i++) {
    cin >> t >> r;
    sor[r] = t;
    poz[r] = i;
    maxr = max(r, maxr);
  }
  sort(v + 1, v + maxr + 1);
  for (int i = 1; i <= maxr; i++) dq.push_back(v[i]);
  lastp = -1;
  for (int i = maxr; i >= 1; i--) {
    if (sor[i] && poz[i] > lastp) {
      tt = sor[i];
      lastp = poz[i];
    }
    if (tt == 2) {
      v[i] = dq.front();
      dq.pop_front();
    } else {
      v[i] = dq.back();
      dq.pop_back();
    }
  }
  for (int i = 1; i <= n; i++) cout << v[i] << " ";
  return 0;
}
