#include <bits/stdc++.h>
using namespace std;
vector<int> prod, nondesc, nonasc;
vector<pair<int, int> > query;
stack<pair<int, int> > relev;
vector<int> res;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < int(n); i++) {
    cin >> a;
    prod.push_back(a);
  }
  for (int i = 0; i < int(m); i++) {
    cin >> a >> b;
    query.push_back(make_pair(a, b));
  }
  int vmax = 0;
  for (int i = (int)(m - 1); i >= int(0); i--) {
    if (vmax >= query[i].second) continue;
    vmax = query[i].second;
    relev.push(query[i]);
  }
  pair<int, int> q = relev.top();
  relev.pop();
  int sz = ((int)(res).size());
  int remain = n;
  for (int i = (int)(n - 1); i >= int(q.second); i--) {
    res.push_back(prod[i]);
    prod.erase(prod.begin() + i);
    remain--;
  }
  int last = q.first;
  nondesc = prod;
  sort(nondesc.begin(), nondesc.end());
  nonasc = nondesc;
  reverse(nonasc.begin(), nonasc.end());
  int l = 0, r = remain - 1;
  while (((int)(relev).size()) > 0) {
    q = relev.top();
    relev.pop();
    int add = remain - q.second;
    if (last == 1) {
      r -= add;
      for (int i = (int)(remain + l - 1); i >= int(r + 1); i--)
        res.push_back(nondesc[i]);
    } else {
      add += l;
      for (int i = (int)(l); i < (int)(add); i++) res.push_back(nondesc[i]);
      l = add;
    }
    remain = q.second;
    last = q.first;
  }
  sz = ((int)(res).size());
  if (last == 1) {
    for (int i = (int)(r + 1 - 1); i >= int(l); i--) res.push_back(nondesc[i]);
  } else {
    remain += l;
    for (int i = (int)(l); i < (int)(remain); i++) res.push_back(nondesc[i]);
  }
  string s = "";
  for (int i = (int)(((int)(res).size()) - 1); i >= int(0); i--) {
    cout << s << res[i];
    s = " ";
  }
  cout << '\n';
  return 0;
}
