#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  int a[n], b[n], ts[n];
  int bkp[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    bkp[i] = a[i];
    b[i] = 0;
    ts[i] = 0;
  }
  int u = 0;
  int l = 0;
  int p, q;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &p, &q);
    b[q - 1] = p;
    ts[q - 1] = ++u;
    if (l < q - 1) l = q - 1;
  }
  sort(bkp, bkp + l + 1);
  int k = 0;
  int cts = 0;
  int fl = -1, pr = 0;
  for (i = l; i >= 0; i--) {
    if (b[i] != 0 and cts < ts[i]) {
      if (fl == b[i])
        b[i] = 0;
      else
        fl = b[i];
      cts = ts[i];
    }
    if (fl == 2)
      a[i] = bkp[k++], b[i] = fl;
    else
      b[i] = 0;
  }
  if (b[0] == 0) fl = 2;
  for (i = 0; i <= l; i++) {
    if (b[i] != 0) {
      fl = b[i];
      continue;
    }
    if (fl == 2) a[i] = bkp[k++];
  }
  for (i = 0; i < n; i++) printf("%d ", a[i]);
  printf("\n");
  return 0;
}
