#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;

inline void MAX(int &a,const int &b) {if(b>a) a=b;}
inline void MIN(int &a,const int &b) {if(b<a) a=b;}
inline int max(const int &a,const int &b) {return a>b?a:b;}
inline int min(const int &a,const int &b) {return a<b?a:b;}

const int N=2e5+5;

int mx,n,m,a[N],b[N];
int tmp[N],len;

struct BIT {
	int c[N];
	long long d[N];
	inline void addc(int pos,int key) {for(int i=pos ; i<=mx ; i+=i&-i) c[i]+=key;}
	inline void addd(int pos,long long key) {for(int i=pos ; i<=mx ; i+=i&-i) d[i]+=key;}
	inline int sumc(int pos) {int res=0;for(int i=pos ; i ; i-=i&-i) res+=c[i];return res;}
	inline long long sumd(int pos) {long long res=0;for(int i=pos ; i ; i-=i&-i) res+=d[i];return res;}
	inline long long query(int key) {
		return sumd(mx)-sumd(key)+1LL*sumc(key)*tmp[key];
	}
}TA,TB;

struct ask {
	int t,x;
	long long y;
	inline ask (int T=0,int X=0,int Y=0) : t(T),x(X),y(Y) {}
}w[N];

int q;

int main() {
	tmp[++len]=0;
	scanf("%d%d",&n,&m);
	scanf("%d",&q);
	for(int i=1 ; i<=q ; ++i) scanf("%d%d%d",&w[i].t,&w[i].x,&w[i].y),tmp[++len]=w[i].y;
	sort(tmp+1,tmp+len+1);
	mx=unique(tmp+1,tmp+len+1)-tmp-1;
	TA.addc(1,n),TB.addc(1,m);
	long long ans=0;
	for(int i=1 ; i<=q ; ++i) {
		int t=w[i].t,x=w[i].x,y=w[i].y,p=lower_bound(tmp+1,tmp+mx+1,y)-tmp;
		if(t==1) {
			int po=lower_bound(tmp+1,tmp+mx+1,a[x])-tmp;
			ans-=TB.query(po),TA.addc(po,-1),TA.addd(po,-a[x]);
			ans+=TB.query(p),TA.addc(p,1),TA.addd(p,y);
			a[x]=y;
		}
		else {
			int po=lower_bound(tmp+1,tmp+mx+1,b[x])-tmp;
			ans-=TA.query(po),TB.addc(po,-1),TB.addd(po,-b[x]);
			ans+=TA.query(p),TB.addc(p,1),TB.addd(p,y);
			b[x]=y;
		}
		printf("%lld\n",ans);
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define ff first
#define ss second

const double pi=3.1415926535897932384626433832795;
const int inf=1e9;
const ll inf2=1e18;
const int mod=1e9+7;

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int bs=440,N=2e5+3,M=(N+bs-1)/bs;

ll cnt[2][N],sqcnt[2][M];
ll sum[2][N],sqsum[2][M];
ll t,x,y,z,i1,i2,i3,i4;
ll ans=0;
vector<vll> val(2,vll(N,0));
vi diff;

void fun(ll f){
    z=val[t][x];
    i1=lower_bound(all(diff),z)-diff.begin();
    i3=i1;
    while(i3>=0 && (i3/bs)==(i1/bs)){
        ans+=(f*cnt[i2][i3]*z);
        i3--;
    }
    while(i3>=0){
        ans+=(f*sqcnt[i2][i3/bs]*z);
        i3-=bs;
    }
    i3=i1+1;
    while(i3<N && (i3/bs)==(i1/bs)){
        ans+=f*sum[i2][i3];
        i3++;
    }
    while(i3<N && (i3/bs)<M){
        ans+=f*sqsum[i2][i3/bs];
        i3+=bs;
    }
}

void solve(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<pair<int,pii>> qry(q);
    fr(i,0,q){
        cin>>qry[i].ff>>qry[i].ss.ff>>qry[i].ss.ss;
        qry[i].ff--;
        diff.pb(qry[i].ss.ss);
    }
    diff.pb(0);
    sort(all(diff));
    diff.erase(unique(all(diff)),diff.end());
    cnt[0][0]=sqcnt[0][0]=n;
    cnt[1][0]=sqcnt[1][0]=m;
    fr(i,0,q){
        t=qry[i].ff;x=qry[i].ss.ff;y=qry[i].ss.ss;
        i2=1-t;
        fun(-1);
        cnt[t][i1]--;
        sqcnt[t][i1/bs]--;
        sum[t][i1]-=z;
        sqsum[t][i1/bs]-=z;
        val[t][x]=y;
        fun(1);
        cnt[t][i1]++;
        sqcnt[t][i1/bs]++;
        sum[t][i1]+=y;
        sqsum[t][i1/bs]+=y;
        cout<<ans<<endl;
    }
    return;
}

int main()
{
    boost();
    
    int tc=1;
    //cin>>tc;
    while(tc--)
        solve();
    return 0;
}