#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long int;
using ld = long double;

class BIT{
private:
    vector<ll> a;
    int n;
public:
    BIT(int len){
        a = vector<ll>(len+1, 0);
        n = len;
    }

    void add(int ind, ll x){
        ind++;
        while(ind <= n){
            a[ind] += x;
            ind += ind & (-ind);
        }
    }

    ll sum_sub(int end){
        end++;
        ll ans = 0;
        while(end > 0){
            ans += a[end];
            end -= end & (-end);
        }
        return ans;
    }

    ll sum(int start, int end){
        return sum_sub(end)-sum_sub(start-1);
    }
};

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> t(q), x(q), y(q);
    for(int i = 0; i < q; i++) cin >> t[i] >> x[i] >> y[i];

    map<int, int> trans1;
    for(int i = 0; i < q; i++){
        x[i]--;
        trans1[y[i]] = 1;
    }
    {
        trans1[0] = 0;
        int i = 0;
        for(auto &p: trans1){
            p.second = i++;
        }
    }

    vector<ll> a(n, 0);
    vector<ll> b(m, 0);
    BIT acount(trans1.size()+1), bcount(trans1.size()+1);
    BIT asum(trans1.size()+1), bsum(trans1.size()+1);
    acount.add(0, n); bcount.add(0, m);
    ll ans = 0;
    for(int turn = 0; turn < q; turn++){
        if(t[turn] == 1){
            ans -= a[x[turn]] * bcount.sum(0, trans1[a[x[turn]]]);
            ans -= bsum.sum(trans1[a[x[turn]]]+1, trans1.size());

            acount.add(trans1[a[x[turn]]], -1);
            asum.add(trans1[a[x[turn]]], -a[x[turn]]);
            a[x[turn]] = y[turn];
            acount.add(trans1[a[x[turn]]], 1);
            asum.add(trans1[a[x[turn]]], a[x[turn]]);

            ans += a[x[turn]] * bcount.sum(0, trans1[a[x[turn]]]);
            ans += bsum.sum(trans1[a[x[turn]]]+1, trans1.size());
        }else{
            ans -= b[x[turn]] * acount.sum(0, trans1[b[x[turn]]]);
            ans -= asum.sum(trans1[b[x[turn]]]+1, trans1.size());

            bcount.add(trans1[b[x[turn]]], -1);
            bsum.add(trans1[b[x[turn]]], -b[x[turn]]);
            b[x[turn]] = y[turn];
            bcount.add(trans1[b[x[turn]]], 1);
            bsum.add(trans1[b[x[turn]]], b[x[turn]]);

            ans += b[x[turn]] * acount.sum(0, trans1[b[x[turn]]]);
            ans += asum.sum(trans1[b[x[turn]]]+1, trans1.size());
        }
        cout << ans << endl;
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,Q;
int T[202020],X[202020],Y[202020];
vector<int> V;
int A[202020],B[202020];

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	void set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};
BIT<ll,20> Anum,Asum,Bnum,Bsum;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	V.push_back(0);
	cin>>N>>M>>Q;
	FOR(i,Q) {
		cin>>T[i]>>X[i]>>Y[i];
		X[i]--;
		V.push_back(Y[i]);
	}
	sort(ALL(V));
	V.erase(unique(ALL(V)),V.end());
	Anum.add(0,N);
	Bnum.add(0,M);
	ll sum=0;
	FOR(i,Q) {
		Y[i]=lower_bound(ALL(V),Y[i])-V.begin();
		if(T[i]==1) {
			//del
			x=A[X[i]];
			sum-=Bnum(x)*V[x];
			sum+=Bsum(x);
			Anum.add(x,-1);
			Asum.add(x,-V[x]);
			//add
			x=A[X[i]]=Y[i];
			sum+=Bnum(x)*V[x];
			sum-=Bsum(x);
			Anum.add(x,1);
			Asum.add(x,V[x]);
		}
		else {
			//del
			x=B[X[i]];
			sum-=Anum(x)*V[x];
			sum+=Asum(x);
			Bnum.add(x,-1);
			Bsum.add(x,-V[x]);
			//add
			x=B[X[i]]=Y[i];
			sum+=Anum(x)*V[x];
			sum-=Asum(x);
			Bnum.add(x,1);
			Bsum.add(x,V[x]);
		}
		cout<<sum<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
