#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0), cout.precision(15);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<int> sa(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sa[i] = a[i];
  }
  vector<int> r(m + 1), t(m + 1);
  int qs = 0;
  for (int i = 0; i < m; i++) {
    int ti, ri;
    cin >> ti >> ri;
    while ((qs > 0) && (r[qs - 1] <= ri)) {
      qs--;
    }
    r[qs] = ri;
    t[qs] = ti;
    qs++;
  }
  r[qs] = 0;
  t[qs] = 0;
  qs++;
  int sl = 1, sr = r[0];
  sort(sa.begin() + sl, sa.begin() + sr + 1);
  for (int i = 0; i < qs - 1; i++) {
    for (int j = r[i]; j > r[i + 1]; j--) {
      if (t[i] == 1) {
        a[j] = sa[sr--];
      } else {
        a[j] = sa[sl++];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != 1) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}
