#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  long long update[n];
  memset(update, -1, sizeof(update));
  long long t[m], r[m];
  long long maxr = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    long long tt, tr;
    cin >> tt >> tr;
    tr--;
    t[i] = tt, r[i] = tr;
    update[r[i]] = i;
    maxr = max(maxr, r[i]);
  }
  multiset<long long> s;
  for (int i = 0; i <= maxr; i++) s.insert(a[i]);
  long long last = -1;
  for (int i = n - 1; i >= 0; i--) {
    last = max(last, update[i]);
    if (last == -1) continue;
    if (t[last] == 1) {
      auto it = s.end();
      it--;
      long long temp = *(it);
      s.erase(it);
      a[i] = temp;
    } else {
      long long temp = *(s.begin());
      s.erase(s.begin());
      a[i] = temp;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
