#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int n, m, a[200005], t[200005], r[200005];
vector<pair<int, int> > s;
multiset<int> sa;
void code() {
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) cin >> t[i] >> r[i];
  int cur = 0;
  for (i = m - 1; i >= 0; i--) {
    if (r[i] > cur) {
      s.push_back({r[i], t[i]});
      cur = r[i];
    }
  }
  reverse((s).begin(), (s).end());
  s.push_back({0, -1});
  for (i = 0; i < s[0].first; i++) sa.insert(a[i]);
  for (i = 1; i < s.size(); i++) {
    for (j = s[i - 1].first - 1; j >= s[i].first; j--) {
      if (s[i - 1].second == 1)
        a[j] = *sa.rbegin();
      else
        a[j] = *sa.begin();
      sa.erase(sa.find(a[j]));
    }
  }
  for (i = 0; i < n; i++) cout << a[i] << " ";
}
int main() {
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    code();
  }
}
