// ~~ icebear love attttttt ~~
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int n, m, k;
array<int, 3> a[N];
int sfmin[N], sfans[N], ans[N], pfsum[N];
deque<int> dq;
void init(void) {
cin >> n >> m >> k;
FOR(i, 1, k) cin >> a[i][0] >> a[i][1], a[i][1]--, a[i][2] = i;
a[++k] = {1, 1, 0};
a[++k] = {n, m, 0};
}
int bs(int x) {
int l = 0, r = (int)dq.size() - 1, res = 0;
while(l <= r) {
int mid = (l + r) >> 1;
if (a[dq[mid]][1] < x) res = mid, l = mid + 1;
else r = mid - 1;
}
return res;
}
void process(void) {
sort(a + 1, a + k + 1);
sfmin[k] = a[k][1];
FORR(i, k - 1, 0) {
sfans[i] = sfans[i + 1] + (a[i + 1][0] - a[i][0]) * sfmin[i + 1];
sfmin[i] = min(sfmin[i + 1], a[i][1]);
}
FOR(i, 1, k) {
while(!dq.empty() && a[dq.back()][1] >= a[i - 1][1]) dq.pop_back();
if (!dq.empty()) pfsum[dq.size()] = pfsum[dq.size() - 1] + (a[i - 1][0] - a[dq.back()][0]) * a[i - 1][1];
dq.pb(i - 1);
int x = bs(sfmin[i + 1]);
ans[a[i][2]] = (a[i + 1][0] - a[dq[x]][0]) * sfmin[i + 1] + sfans[i + 1] + pfsum[x];
}
FOR(i, 1, k - 2) cout << ans[i] << ' ';
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4gaWNlYmVhciBsb3ZlIGF0dHR0dHR0IH5+CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGludCBsb25nIGxvbmcKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgcGFpcjxpbnQsIGludD4gaWk7CnR5cGVkZWYgcGFpcjxpbnQsIGlpPiBpaWk7Cgp0ZW1wbGF0ZTxjbGFzcyBUPgogICAgYm9vbCBtaW5pbWl6ZShUICZhLCBjb25zdCBUICZiKSB7CiAgICAgICAgaWYgKGEgPiBiKSByZXR1cm4gYSA9IGIsIHRydWU7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQoKdGVtcGxhdGU8Y2xhc3MgVD4KICAgIGJvb2wgbWF4aW1pemUoVCAmYSwgY29uc3QgVCAmYikgewogICAgICAgIGlmIChhIDwgYikgcmV0dXJuIGEgPSBiLCB0cnVlOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KCiNkZWZpbmUgRk9SKGksYSxiKSBmb3IoaW50IGk9KGEpOyBpPD0oYik7ICsraSkKI2RlZmluZSBGT1JSKGksYSxiKSBmb3IoaW50IGk9KGEpOyBpPj0oYik7IC0taSkKI2RlZmluZSBSRVAoaSwgbikgZm9yKGludCBpPTA7IGk8KG4pOyArK2kpCiNkZWZpbmUgUkVEKGksIG4pIGZvcihpbnQgaT0obiktMTsgaT49MDsgLS1pKQojZGVmaW5lIE1BU0soaSkgKDFMTCA8PCAoaSkpCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgcGIgcHVzaF9iYWN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