#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int k = 0;
  unordered_map<int, int> r2t, r2i;
  for (int i = 0; i < m; ++i) {
    int t, r;
    cin >> t >> r;
    k = max(k, r);
    r2t[r - 1] = t, r2i[r - 1] = i;
  }
  sort(a.begin(), a.begin() + k);
  vector<int> b(k);
  int l = 0, u = k - 1;
  for (int t = 0, i = -1, r = k - 1; r >= 0; --r) {
    if (r2t[r] && r2i[r] > i) {
      t = r2t[r], i = r2i[r];
    }
    if (t == 1) {
      b[r] = a[u--];
    } else {
      b[r] = a[l++];
    }
  }
  for (int i = 0; i < k; ++i) {
    cout << b[i] << ' ';
  }
  for (int i = k; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << endl;
}
void init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main() {
  init();
  solve();
  return 0;
}
