#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], ord[maxn], oper[maxn], ans[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    int op, r;
    cin >> op >> r;
    ord[r] = i, oper[r] = op;
  }
  int R;
  for (int i = n; i >= 1; i--) {
    if (oper[i]) {
      R = i;
      break;
    } else {
      ans[i] = a[i];
    }
  }
  sort(a + 1, a + 1 + R);
  int now = 0, nowop = 0, f = 1, t = R;
  for (int i = R; i >= 1; i--) {
    if (oper[i] && ord[i] > now) {
      now = ord[i];
      nowop = oper[i];
    }
    if (nowop == 1) {
      ans[i] = a[t--];
    } else {
      ans[i] = a[f++];
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
