#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, m, i, j;
  cin >> n >> m;
  vector<int> a(n);
  for (i = 0; i < n; i++) cin >> a[i];
  int t[m], r[m], ti, ri, b[n];
  int s = 0;
  for (i = 0; i < m; i++) {
    cin >> ti >> ri;
    while (s > 0 && ri >= r[s - 1]) {
      s--;
    }
    t[s] = ti, r[s] = ri;
    s++;
  }
  int bl = 0, br = r[0];
  r[s] = 0;
  s++;
  for (i = 0; i < br; i++) b[i] = a[i];
  sort(b, b + br);
  for (i = 1; i < s; i++) {
    for (j = r[i - 1]; j > r[i]; j--)
      a[j - 1] = (t[i - 1] == 1) ? b[--br] : b[bl++];
  }
  for (i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
