#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v;
  multiset<long long> s;
  vector<pair<long long, long long> > process;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  for (long long i = (long long)(1); i <= (long long)(m); i++) {
    long long t, r;
    cin >> t >> r;
    while (!process.empty() && process.back().second < r) process.pop_back();
    process.push_back(make_pair(t, r - 1));
  }
  process.push_back(make_pair(1, -1));
  long long ctr = 0, last = 0, last_t = 0;
  vector<long long> ans;
  for (auto p : process) {
    if (ctr == 0) {
      for (long long i = (long long)(n - 1); i >= (long long)(p.second + 1);
           i--)
        ans.push_back(v[i]);
      for (long long i = (long long)(0); i <= (long long)(p.second); i++)
        s.insert(v[i]);
    } else {
      long long diff = last - p.second;
      if (last_t == 1) {
        for (long long i = (long long)(1); i <= (long long)(diff); i++) {
          ans.push_back(*s.rbegin());
          s.erase(--s.end());
        }
      } else {
        for (long long i = (long long)(1); i <= (long long)(diff); i++) {
          ans.push_back(*s.begin());
          s.erase(s.begin());
        }
      }
    }
    ctr++;
    last = p.second;
    last_t = p.first;
  }
  reverse((ans).begin(), (ans).end());
  for (long long x : ans) cout << x << ' ';
}
