#include <bits/stdc++.h>
using namespace std;

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
#define MAXN 300005
int MOD = 1e9 + 7;
ll power(ll a, ll b) { //a^b
    ll res = 1;
    a = a % MOD;
    while (b > 0) {
        if (b & 1) {res = (res * a) % MOD; b--;}
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}
ll fermat_inv(ll y) {return power(y, MOD - 2);}
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
ll min(ll a, ll b) {return (a > b) ? b : a;}
ll max(ll a, ll b) {return (a > b) ? a : b;}

struct node{
    ll s,c;
    node(){
        c=s=0;
    }
    node operator +(const node& other){
        node sum=node();
        sum.s=s+other.s;
        sum.c=c+other.c;
        return sum;
    }
};
struct SegTree {
    vector<node>t;
    ll n;
    SegTree(ll n){
        this->n = n;
        t.assign(4*n+10,node());
    }
    node sum(ll v,ll tl,ll tr,ll l,ll r)
    {
        if(l>r)
            return node();
        if(l==tl&&r==tr)
            return t[v];
        ll tm=(tl+tr)/2;
        return sum(v*2,tl,tm,l,min(r,tm))+sum(v*2+1,tm+1,tr,max(l,tm+1),r);
    }
    ll sum(ll l,ll r){
        return sum(1,1,n,l,r).s;
    }
    ll cnt(ll l,ll r){
        return sum(1,1,n,l,r).c;
    }
    void update(ll v,ll tl,ll tr,ll pos,ll new_val,ll cnt)
    {
        if(tl==tr)
            t[v].s+=new_val,t[v].c+=cnt;
        else{
            ll tm=(tl+tr)/2;
            if(pos<=tm)
                update(2*v,tl,tm,pos,new_val,cnt);
            else
                update(2*v+1,tm+1,tr,pos,new_val,cnt);
            t[v]=t[2*v]+t[2*v+1];
        }
    }
    void update(ll idx,ll a,ll c){
        update(1,1,n,idx,a,c);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int te = 1;
    //cin >> te;
    //SieveOfEratosthenes(1000000);
    //factorial(1000005);
    while (te--) {
        int n,m,q;
        cin>>n>>m>>q;
        ll ans=0,t[q],x[q],y[q],a[n+1]={0},b[m+1]={0};
        map<int,int>mp;
        for(int i=0;i<q;i++){
            cin>>t[i]>>x[i]>>y[i];
            mp[y[i]]++;
        }
        int c=1;
        for(auto i:mp)
            mp[i.ff]=c++;
        SegTree S(c+5),T(c+5);
        for(int i=0;i<n;i++)
        	S.update(mp[a[i+1]],a[i+1],1);
        for(int i=0;i<m;i++)
        	T.update(mp[b[i+1]],b[i+1],1);
        for(int i=0;i<q;i++){
            if(t[i]==1){
                ans-=T.sum(mp[a[x[i]]]+1,c);
                ans-=a[x[i]]*T.cnt(1,mp[a[x[i]]]);
                //cout<<ans<<' ';
                S.update(mp[a[x[i]]],-a[x[i]],-1);
                a[x[i]]=y[i];
                S.update(mp[a[x[i]]],a[x[i]],1);
                ans+=T.sum(mp[a[x[i]]]+1,c);
                ans+=a[x[i]]*T.cnt(1,mp[a[x[i]]]);
            }
            else{
                ans-=S.sum(mp[b[x[i]]]+1,c);
                ans-=b[x[i]]*S.cnt(1,mp[b[x[i]]]);
                ///cout<<ans<<' ';
                T.update(mp[b[x[i]]],-b[x[i]],-1);
                b[x[i]]=y[i];
                T.update(mp[b[x[i]]],b[x[i]],1);
                ans+=S.sum(mp[b[x[i]]]+1,c);
                ans+=b[x[i]]*S.cnt(1,mp[b[x[i]]]);
            }
            cout<<ans<<'\n';
        }
    }
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

template <typename T>
class Seg_Tree{
public: // 0-index
	vector<T> dat;
	T initial,M;
	int n;
	T unite(T a,T b){//
		return a + b;
	}
	void initsize(int n0,T initial_,T M_){
		M = M_;
		initial = initial_;
		int k=1;
		while(1){
			if(n0<=k){
				n=k;
				dat.resize(2*n-1);
				for(int i=0;i<2*n-1;i++)dat[i]=initial;
				break;
			}
			k*=2;
		}
	}
 
	//i banme wo x nisuru
	void update(int i,T x){
		i += n-1;
		dat[i] = x;
		while(i>0){
			i = (i-1) / 2;
			dat[i] = unite(dat[i*2+1],dat[i*2+2]);
		}
	}
 
	//[a,b)
	T query0(int a,int b,int k,int l,int r){
		if(r<=a || b<=l)return initial;
		if(a<=l && r<=b)return dat[k];
		else{
			T vl = query0(a,b,k*2+1,l,(l+r)/2);
			T vr = query0(a,b,k*2+2,(l+r)/2,r);
			return unite(vl,vr);
		}
	}
 
	//return [a,b)
	T query(int a,int b){
		return query0(a,b,0,0,n);
	}
};

map<ll,int> ma;
int index_ = 1;
ll ind(ll y){
	if(ma[y]) return ma[y];
	ma[y] = index_;
	index_++;
	return ma[y];
}

int main(){

	int N,M,Q;
	cin >> N >> M >> Q;
	vector< vector<ll> > A(2);
	A[0].resize(N,0);
	A[1].resize(M,0);
	
	vector<ll> T(Q),X(Q),Y(Q);

	FOR(i,0,Q) cin >> T[i] >> X[i] >> Y[i];
	vector<ll> useY;
	useY.push_back(0);
	FOR(i,0,Q) useY.push_back(Y[i]);

	sort(useY.begin(),useY.end());
	FOR(i,0,useY.size()) ind(useY[i]);

	vector< Seg_Tree<ll> > num(2);//個数
	vector< Seg_Tree<ll> > sum(2);//和
	num[0].initsize(index_+3,0,0);
	num[1].initsize(index_+3,0,0);
	sum[0].initsize(index_+3,0,0);
	sum[1].initsize(index_+3,0,0);
	num[0].update(1,N);
	num[1].update(1,M);

	ll ans = 0;

	FOR(i,0,Q){
		int change = T[i]-1;
		int stay = (change+1) % 2;
		int j = X[i] - 1;

		ll min_num = num[stay].query( 0 , ind(A[change][j]) );
		ll from = A[change][j];
		A[change][j] = Y[i];
		ll to = Y[i];
		ans -= min_num * from;
		ans -= sum[stay].query( ind(from) , 400003 );
		min_num = num[stay].query( 0 , ind(to) );
		ans += min_num * to;
		ans += sum[stay].query( ind(to) , 400003);

		int index = ind(from);
		ll cnt = num[change].query(index,index+1);
		num[change].update(index , cnt-1);
		sum[change].update(index , cnt*from-from);

		index = ind(to);
		cnt = num[change].query(index,index+1);
		num[change].update(index , cnt+1);
		sum[change].update(index , (cnt+1)*to);
		cout << ans << endl;
	}
}
