//Time to take charge!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 200110LL
#define MOD 1000000007LL
#define INF 1000000000000000000LL

ll modularExp(ll x, ll n) {
    x %= MOD;
    if (n == 0) {
        return 1;
    }else if (n & 1) {
        return (x * (modularExp((x * x) % MOD, n / 2)) % MOD) % MOD;
    }else{
        return modularExp((x * x) % MOD, n / 2) % MOD;
    }
}

ll modularInverse(ll x) {
    return modularExp(x, MOD - 2) % MOD;
}

ll ftA[MAX], ftB[MAX];
ll ftASum[MAX], ftBSum[MAX];

void update(ll i, ll val, ll ft[]){
      while(i < MAX){
            ft[i] += val;
            i += (i & (-i));
      }
}

ll query(ll i, ll ft[]){
      ll ret = 0;
      while(i > 0){
            ret += ft[i];
            i -= (i & (-i));
      }
      return ret;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif

    ll t = 1;
    //cin>>t;
    while (t--) {
        ll n, m, q;
        cin>>n>>m>>q;
        ll t[q], x[q], y[q];
        set <ll> cc;
        cc.insert(0);
        for (ll i = 0; i < q; i++) {
            cin>>t[i]>>x[i]>>y[i];
            cc.insert(y[i]);
        }
        map <ll, ll> ind;
        ll index = 1;
        for (ll it: cc) {
            ind[it] = (index++);
        }
        memset(ftA, 0, sizeof(ftA));
        memset(ftB, 0, sizeof(ftB));
        memset(ftASum, 0, sizeof(ftASum));
        memset(ftBSum, 0, sizeof(ftBSum));
        ll a[n + 10] = {}, b[m + 10] = {};
        for (ll i = 1; i <= n; i++) {
            update(ind[0], 1, ftA);
        }
        for (ll i = 1; i <= m; i++) {
            update(ind[0], 1, ftB);
        }
        ll ans = 0;
        ll prev;
        for (ll i = 0; i < q; i++) {
            if (t[i] == 1) {
                prev = a[x[i]];
                ans -= (prev * query(ind[prev] - 1, ftB));
                ans -= (query(MAX - 1, ftBSum) - query(ind[prev] - 1, ftBSum));
                update(ind[prev], -1, ftA);
                update(ind[prev], (-1 * prev), ftASum);

                a[x[i]] = y[i];
                ans += (y[i] * query(ind[y[i]] - 1, ftB));
                ans += (query(MAX - 1, ftBSum) - query(ind[y[i]] - 1, ftBSum));
                update(ind[y[i]], 1, ftA);
                update(ind[y[i]], y[i], ftASum);
            } else {
                prev = b[x[i]];
                ans -= (prev * query(ind[prev], ftA));
                ans -= (query(MAX - 1, ftASum) - query(ind[prev], ftASum));
                update(ind[prev], -1, ftB);
                update(ind[prev], (-1 * prev), ftBSum);

                b[x[i]] = y[i];
                ans += (y[i] * query(ind[y[i]], ftA));
                ans += (query(MAX - 1, ftASum) - query(ind[y[i]], ftASum));
                update(ind[y[i]], 1, ftB);
                update(ind[y[i]], y[i], ftBSum);
            }
            cout<<ans<<"\n";
        }
    }
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 200010, mod = 1000000007;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
struct Seg{
	int tot,s[maxn*100],v[maxn*100],rt,ls[maxn*100],rs[maxn*100];
	void psp(int k) {s[k]=s[ls[k]]+s[rs[k]],v[k]=v[ls[k]]+v[rs[k]];}
	void ins(int&k,int l,int r,int p,int VL,int VL2)
	{
		if(!k) k=++tot;
		if(l==r) return s[k]+=VL,v[k]+=VL2,void();int mid=l+r>>1;
		p>mid?ins(rs[k],mid+1,r,p,VL,VL2):ins(ls[k],l,mid,p,VL,VL2),psp(k);
	}
	int asks(int k,int l,int r,int L,int R)
	{
		if(l>R||L>r||!k) return 0;
		if(L<=l&&r<=R) return s[k];int mid=l+r>>1;
		return asks(ls[k],l,mid,L,R)+asks(rs[k],mid+1,r,L,R);
	}
	int askv(int k,int l,int r,int L,int R)
	{
		if(l>R||L>r||!k) return 0;
		if(L<=l&&r<=R) return v[k];int mid=l+r>>1;
		return askv(ls[k],l,mid,L,R)+askv(rs[k],mid+1,r,L,R);
	}
}s1,s2;
int ans,n,m,Q,a[maxn],b[maxn];
signed main()
{
	n=read(),m=read(),Q=read();
	s1.ins(s1.rt,0,1e8,0,0,n);
	s2.ins(s2.rt,0,1e8,0,0,m);
	for(int i=1,x,y;i<=Q;cout<<ans<<'\n',i++)
		if(read()==1)
		{
			x=read();
			ans-=s2.asks(s2.rt,0,1e8,a[x]+1,1e8)+a[x]*s2.askv(s2.rt,0,1e8,0,a[x]);
			s1.ins(s1.rt,0,1e8,a[x],-a[x],-1);
			a[x]=read();
			s1.ins(s1.rt,0,1e8,a[x],a[x],1);
			ans+=s2.asks(s2.rt,0,1e8,a[x]+1,1e8)+a[x]*s2.askv(s2.rt,0,1e8,0,a[x]);
		}
		else
		{
			x=read();
			ans-=s1.asks(s1.rt,0,1e8,b[x]+1,1e8)+b[x]*s1.askv(s1.rt,0,1e8,0,b[x]);
			s2.ins(s2.rt,0,1e8,b[x],-b[x],-1);
			b[x]=read();
			s2.ins(s2.rt,0,1e8,b[x],b[x],1);
			ans+=s1.asks(s1.rt,0,1e8,b[x]+1,1e8)+b[x]*s1.askv(s1.rt,0,1e8,0,b[x]);
		}
	return 0;
}