#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n, m;
struct node {
  int order, num;
};
int a[MAXN];
node b[MAXN];
int siz;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  siz = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &b[siz].order, &b[siz].num);
    while (siz > 0 && b[siz].num > b[siz - 1].num) {
      b[siz - 1] = b[siz];
      siz--;
    }
    while (siz > 0 && b[siz].order == b[siz - 1].order) {
      siz--;
    }
    siz++;
  }
  sort(a, a + b[0].num);
  deque<int> res;
  deque<int> ansque;
  for (int i = 0; i < b[0].num; i++) {
    if (b[0].order == 2) {
      res.push_front(a[i]);
    } else {
      res.push_back(a[i]);
    }
  }
  b[siz].num = 0;
  for (int i = 0; i < siz; i++) {
    int lar = b[i].num - b[i + 1].num;
    if (i & 1) {
      for (int j = 0; j < lar; j++) {
        ansque.push_front(res.front());
        res.pop_front();
      }
    } else {
      for (int j = 0; j < lar; j++) {
        ansque.push_front(res.back());
        res.pop_back();
      }
    }
  }
  int yi = 0;
  for (deque<int>::iterator it = ansque.begin(); it != ansque.end(); it++) {
    a[yi++] = *it;
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  return 0;
}
