#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
template <class T>
inline T BigMod(T Base, T power, T M = 1000000007) {
  if (power == 0) return 1;
  if (power & 1)
    return ((Base % M) * (BigMod(Base, power - 1, M) % M)) % M;
  else {
    T y = BigMod(Base, power / 2, M) % M;
    return (y * y) % M;
  }
}
template <class T>
inline T ModInv(T A, T M = 1000000007) {
  return BigMod(A, M - 2, M);
}
int fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0};
int fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int arr[200005], a[200005], b[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  stack<int> st;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    while (!st.empty() && b[st.top()] <= b[i]) st.pop();
    st.push(i);
  }
  vector<int> indx;
  while (!st.empty()) {
    indx.push_back(st.top());
    st.pop();
  }
  reverse(indx.begin(), indx.end());
  int x = indx[0];
  int l = b[x] + 1;
  int r = n;
  sort(arr + 1, arr + b[x] + 1);
  vector<pair<int, int> > ans;
  if (l != n + 1) ans.push_back(pair<int, int>(l, r));
  l = 1;
  r = b[x];
  if (a[x] == 2) {
    l = b[x];
    r = 1;
  }
  for (int i = 1; i < indx.size(); i++) {
    if (a[indx[i]] == a[indx[i - 1]]) continue;
    if (l < r) {
      ans.push_back(pair<int, int>(l + b[indx[i]], r));
      int temp = l;
      l = l + b[indx[i]] - 1;
      r = temp;
    } else {
      ans.push_back(pair<int, int>(l - b[indx[i]], r));
      int temp = l;
      l = l - b[indx[i]] + 1;
      r = temp;
    }
  }
  ans.push_back(pair<int, int>(l, r));
  vector<pair<int, int> > res;
  int pk = n;
  for (int i = 0; i < ans.size(); i++) {
    pair<int, int> xx = ans[i];
    if (xx.second > xx.first) {
      for (int j = xx.second; j >= xx.first; j--) {
        res.push_back(pair<int, int>(pk--, arr[j]));
      }
    } else {
      for (int j = xx.second; j <= xx.first; j++) {
        res.push_back(pair<int, int>(pk--, arr[j]));
      }
    }
  }
  sort(res.begin(), res.end());
  for (int i = 0; i < res.size(); i++) cout << res[i].second << " ";
  return 0;
}
