#include <bits/stdc++.h>
using namespace std;
int a[200200];
int qwe[200200];
int t[200200];
vector<pair<int, int> > v;
void go(int l, int r, int it) {
  if (it == v.size()) {
    if (l > r) swap(l, r);
    if (v[it - 1].second == 1) {
      for (int i = l; i <= r; i++) {
        printf("%d ", a[i]);
      }
    } else {
      for (int i = r; i >= l; i--) {
        printf("%d ", a[i]);
      }
    }
    return;
  } else {
    if (l <= r) {
      if (v[it].second == 1) {
        go(l, l + v[it].first - 1, it + 1);
        for (int i = l + v[it].first; i <= r; i++) {
          printf("%d ", a[i]);
        }
      } else {
        go(l + v[it].first - 1, l, it + 1);
        for (int i = l + v[it].first; i <= r; i++) {
          printf("%d ", a[i]);
        }
      }
    } else {
      if (v[it].second == 1) {
        go(l - v[it].first + 1, l, it + 1);
        for (int i = l - v[it].first; i >= r; i--) {
          printf("%d ", a[i]);
        }
      } else {
        go(l, l - v[it].first + 1, it + 1);
        for (int i = l - v[it].first; i >= r; i--) {
          printf("%d ", a[i]);
        }
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &t[i], &qwe[i]);
  }
  v.push_back(pair<int, int>(qwe[m - 1], t[m - 1]));
  int it = 0;
  for (int i = m - 2; i >= 0; i--) {
    if (qwe[i] > v[it].first) {
      if (t[i] == v[it].second) {
        v.pop_back();
        it--;
      }
      v.push_back(pair<int, int>(qwe[i], t[i]));
      it++;
    }
  }
  reverse(v.begin(), v.end());
  sort(a, a + v[0].first);
  go(0, v[0].first - 1, 0);
  for (int i = v[0].first; i < n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
