#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e5 + 5;
inline int read()
{
    int w = 0, f = 1;
    char ch = getchar();
    while (ch < '0' or ch > '9')
    {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    while (ch >= '0' and ch <= '9')
        w = w * 10 + ch - '0', ch = getchar();
    return w * f;
}
int L[maxn], R[maxn], A[maxn], N, M, K;
bool check(int limit)
{
    for (int i = 1; i <= K; i++)
        L[i] = ((A[i] * M - limit + N - 1) / N), R[i] = ((A[i] * M + limit) / N);
    for (int i = 1; i <= K; i++)
        L[i] = max(L[i], 0ll);
    for (int i = 1; i <= K; i++)
        if (L[i] > R[i])
            return 0;
    int lsum = 0, rsum = 0;
    for (int i = 1; i <= K; i++)
        lsum += L[i], rsum += R[i];
    if (lsum <= M and rsum >= M)
        return 1;
    return 0;
}
signed main()
{
    scanf("%lld%lld%lld", &K, &N, &M);
    for (int i = 1; i <= K; i++)
        scanf("%lld", &A[i]);
    int l = 0, r = M * N;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
            r = mid - 1;
        else
            l = mid + 1;
    }
    check(l);
    int lsum = 0;
    for (int i = 1; i <= K; i++)
        lsum += L[i];
    int res = M - lsum;
    for (int i = 1; i <= K; i++)
    {
        printf("%lld ", min(L[i] + res, R[i]));
        res -= min(L[i] + res, R[i]) - L[i];
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll N,M,Q;
map<ll,ll>mp;
map<ll,ll>mp1;
P dat[2][800005];
ll n;
void init(ll n_){
  n=1;
while(n<=n_)n*=2;
  for(ll i=0;i<2*n-1;i++){
  dat[0][i]=P(0,0);
    dat[1][i]=P(0,0);
  }
}
void update(ll j,ll k,ll a){
 ll m=mp1.at(k); k+=n-1;
dat[j][k].first+=a;dat[j][k].second+=a*m;
  while(0<k){
  k=(k-1)/2;
    dat[j][k].first=(dat[j][2*k+1].first+dat[j][2*k+2].first);
    dat[j][k].second=(dat[j][2*k+1].second+dat[j][2*k+2].second);
  }

}
P query(ll j,ll a,ll b,ll k,ll l,ll r){
if(a<=l&&r<=b)return dat[j][k];
  else if(b<=l||r<=a)return P(0,0);
  else{
    
  P val=query(j,a,b,2*k+1,l,(l+r)/2);
    P var=query(j,a,b,2*k+2,(l+r)/2,r);
    P p(val.first+var.first,val.second+var.second);
    return p;
  
  }

}
int main(){
  cin>>N>>M>>Q;
  set<ll>S;S.insert(0);
  vector<ll>T(Q);vector<ll>X(Q);vector<ll>Y(Q);
  for(ll q=0;q<Q;q++){
  cin>>T[q];cin>>X[q];X[q]--;cin>>Y[q];S.insert(Y[q]);
  }ll I=0;
  for(auto x:S){mp[x]=I;I++;}
  for(auto p:mp){mp1[p.second]=p.first;}vector<ll>A(N);vector<ll>B(M);ll ans=0;
  init(I);update(0,0,N);update(1,0,M);
    for(ll q=0;q<Q;q++){
 if(T[q]==1){
 ans-=query(1,0,mp.at(A[X[q]])+1,0,0,n).first*A[X[q]];
 if(A[X[q]]<Y[q]){
 ans-=query(1,mp.at(A[X[q]])+1,mp.at(Y[q])+1,0,0,n).second;
 }else if(Y[q]<A[X[q]]){
  ans+=query(1,mp.at(Y[q])+1,mp.at(A[X[q]])+1,0,0,n).second;
 }else{}
 ans+=query(1,0,mp.at(Y[q])+1,0,0,n).first*Y[q];update(0,mp.at(A[X[q]]),-1);
             update(0,mp.at(Y[q]),1);A[X[q]]=Y[q];
 }else{
  ans-=query(0,0,mp.at(B[X[q]])+1,0,0,n).first*B[X[q]];
 if(B[X[q]]<Y[q]){
 ans-=query(0,mp.at(B[X[q]])+1,mp.at(Y[q])+1,0,0,n).second;
 }else if(Y[q]<B[X[q]]){
  ans+=query(0,mp.at(Y[q])+1,mp.at(B[X[q]])+1,0,0,n).second;
 }else{}
 ans+=query(0,0,mp.at(Y[q])+1,0,0,n).first*Y[q];update(1,mp.at(B[X[q]]),-1);
             update(1,mp.at(Y[q]),1);B[X[q]]=Y[q];
 }cout<<ans<<endl;
  }

 return 0;
}