#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int a[maxn];
int b[maxn];
int que[maxn];
int c[maxn];
int End;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int js1, js2;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &js1, &js2);
    while (End && que[End] <= js2) End--;
    End++;
    que[End] = js2;
    c[End] = js1;
  }
  sort(a + 1, a + 1 + que[1]);
  for (int i = que[1] + 1; i <= n; i++) b[i] = a[i];
  int left = 1, right = que[1];
  que[End + 1] = 0;
  for (int i = 1; i <= End; i++) {
    if (c[i] == 2) {
      for (int j = left, j1 = que[i]; j <= left + que[i] - que[i + 1] - 1;
           j++, j1--)
        b[j1] = a[j];
      left += que[i] - que[i + 1];
    } else {
      for (int j = right, j1 = que[i]; j >= right + que[i + 1] - que[i] - 1;
           j--, j1--)
        b[j1] = a[j];
      right -= que[i] - que[i + 1];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", b[i]);
  return 0;
}
