#include <bits/stdc++.h>
using namespace std;
class Report {
 public:
  int t, r, ind;
  bool operator<(const Report &p) const {
    if (r == p.r) return ind > p.ind;
    return r > p.r;
  }
};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  vector<Report> v(m + 1);
  v[0].t = v[0].r = v[0].ind = 0;
  for (int i = 1; i <= m; i++) {
    int t, r;
    scanf("%d%d", &t, &r);
    v[i].t = t, v[i].r = r, v[i].ind = i;
  }
  sort(v.begin(), v.end());
  vector<int> sol(n + 1);
  for (int i = v[0].r + 1; i <= n; i++) sol[i] = a[i];
  sort(a.begin() + 1, a.begin() + v[0].r + 1);
  int left = 1, right = v[0].r;
  for (int i = 0; i < m;) {
    int j = i + 1;
    while (j < m && v[i].ind > v[j].ind) j++;
    int p = v[i].r - v[j].r;
    if (v[i].t == 2) {
      while (p) {
        sol[v[i].r--] = a[left++];
        p--;
      }
    } else {
      while (p) {
        sol[v[i].r--] = a[right--];
        p--;
      }
    }
    i = j;
  }
  for (int i = 1; i <= n; i++) printf("%d ", sol[i]);
  printf("\n");
  return 0;
}
