#include <bits/stdc++.h>
using namespace std;
inline void FAST_IO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <class F, class S>
ostream& operator<<(ostream& os, pair<F, S>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, set<T>& v) {
  os << "(";
  for (auto& i : v) cout << i << ",";
  os << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  os << "(";
  if (v.size()) os << v[0];
  for (int i = 1; i < v.size(); ++i) os << "," << v[i];
  os << ")";
  return os;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  struct info {
    int r, t;
  };
  vector<info> in(m);
  for (int i = 0; i < m; ++i) {
    cin >> in[i].t >> in[i].r;
  }
  vector<info> proc;
  proc.push_back(in.back());
  for (int i = m - 1; i >= 0; i--) {
    if (in[i].r > proc.back().r) {
      proc.push_back(in[i]);
    }
  }
  reverse(proc.begin(), proc.end());
  proc.push_back({0, 0});
  vector<int> b;
  for (int i = 0; i < proc.front().r; ++i) {
    b.push_back(a[i]);
  }
  int l = 0, r = b.size() - 1, next = b.size() - 1;
  sort(b.begin(), b.end());
  for (int i = 1; i < proc.size(); ++i) {
    int amt = proc[i - 1].r - proc[i].r;
    if (proc[i - 1].t == 1) {
      while (amt-- > 0) a[next--] = b[r--];
    } else {
      while (amt-- > 0) a[next--] = b[l++];
    }
  }
  for (auto v : a) cout << v << " ";
  cout << endl;
  return 0;
}
