#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
using namespace std;
long long int power(long long int a, long long int n) {
  if (n == 0) {
    return 1;
  }
  long long int p = power(a, n / 2) % 1000000007;
  p = (p * p) % 1000000007;
  if (n % 2 == 1) {
    p = (p * a) % 1000000007;
  }
  return p;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
const int N = 1e6 + 5;
vector<long long int> sieve(N, 0);
void si() {
  sieve[1] = 1;
  for (int i = 2; i < N; i++) {
    if (sieve[i] == 0) {
      sieve[i] = i;
      for (int j = 2 * i; j < N; j += i) {
        sieve[j] = i;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  vector<long long int> a(n);
  ;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  ;
  vector<pair<long long int, long long int> > r(m, make_pair(0, 0));
  for (int i = 0; i < m; i++) {
    long long int t, x;
    cin >> t >> x;
    r[i].first = t;
    r[i].second = x;
  }
  long long int curr_max = r[m - 1].second;
  long long int type = r[m - 1].first;
  for (int i = m - 2; i >= 0; i--) {
    if (curr_max >= r[i].second) {
      r[i].second = curr_max;
      r[i].first = type;
    } else {
      curr_max = r[i].second;
      type = r[i].first;
    }
  }
  if (type == 1) {
    sort(a.begin(), a.begin() + curr_max);
  } else {
    sort(a.begin(), a.begin() + curr_max, greater<long long int>());
  }
  long long int b = 0, e = curr_max - 2;
  vector<long long int> ans(n, 0);
  for (int i = curr_max - 1; i < n; i++) {
    ans[i] = a[i];
  }
  long long int pos = curr_max - 2;
  long long int prev = curr_max - 1;
  int flag = 0;
  for (int i = 1; i < m; i++) {
    if (r[i].second == r[i - 1].second) {
      continue;
    }
    pos = r[i].second;
    if (r[i].first == r[i - 1].first) {
      for (int i = prev; i >= pos; i--) {
        if (flag == 0) {
          ans[i - 1] = a[e];
          e--;
        } else {
          ans[i - 1] = a[b];
          b++;
        }
      }
      prev = pos - 1;
      continue;
    }
    if (pos < prev) {
      for (int i = prev; i >= pos + 1; i--) {
        if (flag == 0) {
          ans[i - 1] = a[e];
          e--;
        } else {
          ans[i - 1] = a[b];
          b++;
        }
      }
    }
    flag = flag ^ 1;
    if (flag == 1) {
      ans[pos - 1] = a[b];
      b++;
    } else {
      ans[pos - 1] = a[e];
      e--;
    }
    prev = pos - 1;
    if (prev <= 0) {
      break;
    }
  }
  if (prev > 0) {
    for (int i = prev - 1; i >= 0; i--) {
      if (flag == 1) {
        ans[i] = a[b];
        b++;
      } else {
        ans[i] = a[e];
        e--;
      }
    }
  };
  for (long long int i = 0; i < n; i++) cout << ans[i] << " ";
  ;
  cout << "\n";
  return 0;
}
