#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], idx[N], typ[N], ans[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int mx = -1;
  for (int i = 1; i <= m; i++) {
    int type, r;
    cin >> type >> r;
    idx[r] = i;
    typ[r] = type;
    mx = max(mx, r);
  }
  sort(a + 1, a + mx + 1);
  int l = 1, r = mx, now = 0, flag;
  for (int i = mx; i; i--) {
    if (now < idx[i]) {
      now = idx[i];
      flag = typ[i];
    }
    if (flag == 2)
      ans[i] = a[l++];
    else
      ans[i] = a[r--];
  }
  for (int i = 1; i <= mx; i++) cout << ans[i] << " ";
  for (int i = mx + 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
