#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
inline void getInt(int* p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
int n, m;
int a[maxn];
stack<pair<int, int> > b;
multiset<int> s;
std::vector<pair<int, int> > v;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int op, r;
  int q = 0;
  for (int i = 1; i <= m; i++) {
    cin >> op >> r;
    while (!b.empty() && b.top().second <= r) {
      b.pop();
    }
    b.push(make_pair(op, r));
    q = max(q, r);
  }
  for (int i = 1; i <= q; i++) {
    s.insert(a[i]);
  }
  v.push_back(make_pair(0, 0));
  while (!b.empty()) {
    v.push_back(b.top());
    b.pop();
  }
  int last = q;
  for (int j = int(v.size()) - 2; j >= 0; --j) {
    op = v[j + 1].first;
    for (int i = last; i >= v[j].second + 1; i--) {
      if (op == 1) {
        auto it = s.end();
        it--;
        a[i] = *it;
        s.erase(it);
      } else {
        a[i] = (*(s.begin()));
        s.erase(s.begin());
      }
    }
    last = v[j].second;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
inline void getInt(int* p) {
  char ch;
  do {
    ch = getchar();
  } while (ch == ' ' || ch == '\n');
  if (ch == '-') {
    *p = -(getchar() - '0');
    while ((ch = getchar()) >= '0' && ch <= '9') {
      *p = *p * 10 - ch + '0';
    }
  } else {
    *p = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9') {
      *p = *p * 10 + ch - '0';
    }
  }
}
