#include <bits/stdc++.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=1e9+7;
#define rep(i,a) for (int i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";}

//main関数だよーーー
int main() {
	ll K,N,M;
	cin>>K>>N>>M;
	vector<ll> ans(K),p(K);
	rep(i,K) cin>>p[i];
	vector<pair<ll,ll>> q(K);
	ll X=0;
	rep(i,K){
		ans[i]=(M*p[i])/N;
		q[i]={(M*p[i])%N,i};
		X+=q[i].first;
	}
	assert(X%N==0);
	Sore(q);
	X/=N;
	rep(i,X){
		ans[q[i].second]++;
	}
	rep(i,K){
		cout<<ans[i];
		if(i!=K-1) cout<<" ";
		else cout<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
long long x,y,n,m,k,ans,mm[200002],nn[200002],ff[200002],nm;
vector<int>sz[200002];
void add(int a){while(a<=nm)ff[a]++,a+=a&(-a);}
int ask(int a){int ans=0;while(a)ans+=ff[a],a-=a&(-a);return ans;}
int main(){
    scanf("%lld%lld%lld",&n,&m,&k);nm=max(n, m);
    for(int i=1;i<=nm;++i)mm[i]=m+1,nn[i]=n+1;
    for(int i=1;i<=k;++i){scanf("%lld%lld",&x,&y);mm[x]=min(mm[x],y);nn[y]=min(nn[y],x);}
    for(int i=1;i<mm[1];++i)ans+=nn[i]-1,sz[nn[i]].push_back(i);
    for(int i=mm[1];i<=m;++i)sz[1].push_back(i);
    for(int i=1;i<nn[1];++i){for(int j:sz[i])add(j);ans+=ask(mm[i]-1);}
    printf("%lld",ans);
    return 0;
}