#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, s;
cin >> n >> s;
multiset<long long> ms;
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
ms.insert(x);
}
while (s--) {
long long m, c;
cin >> m >> c;
vector<long long> tmp;
tmp.reserve(c);
for (long long i = 0; i < c; i++) {
auto it = prev(ms.end());
long long val = *it;
ms.erase(it);
tmp.push_back(val - m);
}
for (auto x : tmp) ms.insert(x);
}
vector<long long> res(ms.begin(), ms.end());
sort(res.rbegin(), res.rend());
for (auto x : res) cout << x << ' ';
}