#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200001];
vector<int> b;
int dir[200001];
int temp[200001][2];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int t, ri;
  for (int i = 1; i <= m; ++i) {
    cin >> t >> ri;
    temp[ri][0] = i;
    temp[ri][1] = t;
  }
  int i;
  for (i = n; i >= 1; --i) {
    if (temp[i][0] == 0)
      dir[i] = 0;
    else
      break;
  }
  int stop = i;
  int cur;
  int curRow = -1;
  for (; i >= 1; --i) {
    if (curRow < temp[i][0]) {
      cur = temp[i][1];
      curRow = temp[i][0];
    }
    dir[i] = cur;
  }
  if (stop > 1) {
    for (int j = 1; j <= stop; ++j) b.push_back(a[j]);
    sort(b.begin(), b.end());
    int l = 0, r = stop - 1;
    for (int j = stop; j >= 1; --j) {
      if (dir[j] == 1) {
        a[j] = b[r];
        --r;
      } else {
        a[j] = b[l];
        ++l;
      }
    }
  }
  for (int j = 1; j < n; ++j) cout << a[j] << " ";
  cout << a[n] << endl;
  return 0;
}
