#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int rep[n];
  for (int i = 0; i < n; i++) cin >> rep[i];
  deque<pair<int, int>> mang;
  for (int i = 0; i < m; i++) {
    int t, r;
    cin >> t >> r;
    auto next = make_pair(t, r);
    while (mang.size() > 0 && next.second >= mang.front().second)
      mang.pop_front();
    mang.push_front(next);
  }
  mang.push_front(make_pair(0, 0));
  int ans[n];
  auto big = mang.back();
  mang.pop_back();
  for (int i = 0; i < n; i++) ans[i] = 0;
  for (int i = big.second; i < n; i++) {
    ans[i] = rep[i];
  }
  sort(rep, rep + big.second);
  int lp = 0;
  int rp = big.second - 1;
  int pindex = big.second - 1;
  int pdir = big.first;
  while (!mang.size() == 0) {
    auto next = mang.back();
    mang.pop_back();
    for (int i = pindex; i >= next.second; i--) {
      if (pdir == 1) {
        ans[i] = rep[rp--];
      } else {
        ans[i] = rep[lp++];
      }
    }
    pindex = next.second - 1;
    pdir = next.first;
  }
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
