// اَللَهُمَ صَلِ عَلَىَ مُحَمَدٍ وَ آلِ مُحَمَدٍ
#include "bits/stdc++.h"
using namespace std ;
#define int long long
#define pb push_back
#define si size()
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define applejuice ios::sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
const int inf=1e18 ;
const int mod=1e9+7 ;
const int maxn=5*1e5+7 ;
int tt=1 ;
int a[maxn] ;
void solve() {
int n , s ;
cin >> n >> s ;
for(int i=0 ; i<n ; i++) {cin >> a[i] ;}
while(s--) {
int m , c ;
cin >> m >> c ;
sort(a,a+n) ;
reverse(a,a+n) ;
for(int i=0 ; i<c ; i++) {a[i]-=m ;}
}
sort(a,a+n) ;
reverse(a,a+n) ;
for(int i=0 ; i<n ; i++) {cout << a[i] << " " ;}
}
signed main() {
//wrong
applejuice ;
//cin >> tt ;
while(tt--) {solve() ;}
}
/*
5 4
20 12 10 15 18
3 4
4 1
1 3
4 2
*/