#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0), cout.precision(15);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<int> sa(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sa[i] = a[i];
  }
  priority_queue<pair<pair<int, int>, int> > Q;
  int rmax = 0;
  for (int i = 0; i < m; i++) {
    int ti, ri;
    cin >> ti >> ri;
    Q.push(make_pair(make_pair(ri, i), ti));
    rmax = max(rmax, ri);
  }
  sort(sa.begin() + 1, sa.begin() + rmax + 1);
  int last_t = 0, last_r = n, last_i = -1;
  int last_s = 1;
  while (Q.size()) {
    pair<pair<int, int>, int> u = Q.top();
    Q.pop();
    int r = u.first.first, i = u.first.second, t = u.second;
    if (i < last_i) {
      continue;
    }
    if (last_t == 1) {
      for (int j = r + 1; j <= last_r; j++) {
        a[j] = sa[last_s + j - 1];
      }
      if (t == 2) {
        last_s = last_s + r - 1;
      }
    } else if (last_t == 2) {
      for (int j = r + 1; j <= last_r; j++) {
        a[j] = sa[last_s - j + 1];
      }
      if (t == 1) {
        last_s = last_s - r + 1;
      }
    } else {
      if (t == 1) {
        last_s = 1;
      } else {
        last_s = r;
      }
    }
    last_t = t;
    last_i = i;
    last_r = r;
  }
  if (last_t == 1) {
    for (int j = 1; j <= last_r; j++) {
      a[j] = sa[last_s + j - 1];
    }
  } else {
    for (int j = 1; j <= last_r; j++) {
      a[j] = sa[last_s - j + 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != 1) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}
