#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n), brr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<pair<int, int> > cmds;
  while (m--) {
    int t, r;
    cin >> t >> r;
    while (!cmds.empty() && cmds.back().second <= r) cmds.pop_back();
    cmds.push_back({t, r});
  }
  cmds.push_back({1, 0});
  bool rev = false;
  sort(arr.begin(), arr.begin() + cmds[0].second);
  int offsetL = 0, offsetR = n - 1, current = n - 1;
  for (int i = 0; i < (int)cmds.size(); i++) {
    int t = cmds[i].first;
    int r = cmds[i].second;
    while (r <= current) {
      if (rev)
        brr[current--] = arr[offsetL++];
      else
        brr[current--] = arr[offsetR--];
    }
    rev = (t == 2);
  }
  for (int i = 0; i < n; i++) cout << brr[i] << ' ';
  cout << '\n';
  return 0;
}
