#include <cstdio>
#include <cstdlib>
using namespace std;
#define ll long long
const ll MAXN = 400011;

struct fhqTreap {
	ll tot, rt;
	ll val[MAXN], sum[MAXN], sz[MAXN], ls[MAXN], rs[MAXN], rd[MAXN];

	void pushup(ll u) {sz[u] = sz[ls[u]] + sz[rs[u]] + 1; sum[u] = sum[ls[u]] + sum[rs[u]] + val[u];}

	void split(ll u, ll k, ll &x, ll &y) {
		if(!u) {x = y = 0; return;}
		if(val[u] <= k) x = u, split(rs[u], k, rs[u], y);
		else y = u, split(ls[u], k, x, ls[u]);
		pushup(u);
	}

	ll merge(ll u, ll v) {
		if(!u || !v) return u | v;
		if(rd[u] < rd[v]) {rs[u] = merge(rs[u], v); pushup(u); return u;}
		else {ls[v] = merge(u, ls[v]); pushup(v); return v;}
	}

	ll add(ll k) {
		rd[++tot] = rand();
		sz[tot] = 1;
		val[tot] = sum[tot] = k;
		return tot;
	}

	void insert(ll k) {
		ll x, y;
		split(rt, k, x, y);
		rt = merge(merge(x, add(k)), y);
	}

	ll cb(ll k) {
		ll x, y;
		split(rt, k, x, y);
		ll ans = sz[x] * k + sum[y];
		rt = merge(x, y);
		return ans;
	}

	void delet(ll k) {
		ll x, y, z;
		split(rt, k, x, z);
		split(x, k - 1, x, y);
		y = merge(ls[y], rs[y]);
		rt = merge(merge(x, y), z);
	}
} t[2];

ll q;
ll len[2];
ll w[2][MAXN];

ll read() {
	ll X = 0, F = 1; char C = getchar();
	while(C < '0' || C > '9') {if(C == '-')F=-1; C = getchar();}
	while(C >= '0' && C <= '9') {X = X*10+C-'0'; C = getchar();}
	return X * F;
}

int main() {
	ll ans = 0;
	len[1] = read(); len[0] = read(); q = read();
	for(ll i = 0; i < 2; ++i)
		for(ll j = 1; j <= len[i]; ++j)
			t[i].rt = t[i].merge(t[i].rt, t[i].add(0));
	for(ll i = 1, opt, x, y; i <= q; ++i) {
		opt = (read() & 1); x = read(); y = read();
		t[opt].delet(w[opt][x]);
		t[opt].insert(y);
		ans -= t[opt^1].cb(w[opt][x]);
		w[opt][x] = y;
		ans += t[opt^1].cb(w[opt][x]);
		printf("%lld\n", ans);
	}
	return 0;
}
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


template<typename T>
struct BIT{
	vector<T> bit;
	BIT(int n) : bit(n+1) {}
	void add(int a,T w){
		for(int x=++a; x < bit.size(); x+=(x&(-x)) ){
			bit[x] += w;
		}
	}
	// return v[0]+v[1]+...+v[a-1];
	T sum(int a){
		T ret=0;
		for(int x=a;x>0;x-=(x&(-x)) ){
			ret+=bit[x];
		}
		return ret;
	}
};

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);

	int n,m,q;
	cin>>n>>m>>q;
	vector<array<ll,3>> v(q);
	map<int,int> mp;
	for(int i=0;i<q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		b--;
		mp[c]=0;
		v[i]={a,b,c};
	}
	mp[0]=0;
	int now = 0;
	for(auto &i:mp){
		i.second = now;
		now++;
	}
	ll ans = 0;
	int k = now;
	BIT<ll> c1(k),c2(k),s1(k),s2(k);
	int a[n]={},b[m]={};
	c1.add(0,n);
	c2.add(0,m);
	for(int i=0;i<q;i++){
		auto [t,x,y] = v[i];
		int pos = mp[y];
		if(t == 1){
			int pre = mp[a[x]];
			ans -= a[x] * c2.sum(pre);
			ans -= s2.sum(k) - s2.sum(pre);
			c1.add(pre,-1);
			c1.add(pos,1);
			s1.add(pre,-a[x]);
			s1.add(pos,y);
			a[x]=y;
			ans += y * c2.sum(pos);
			ans += s2.sum(k) - s2.sum(pos);
		}
		else{
			int pre = mp[b[x]];
			ans -= b[x] * c1.sum(pre);
			ans -= s1.sum(k) - s1.sum(pre);
			c2.add(pre,-1);
			c2.add(pos,1);
			s2.add(pre,-b[x]);
			s2.add(pos,y);
			b[x]=y;
			ans += y * c1.sum(pos);
			ans += s1.sum(k) - s1.sum(pos);
		}
		cout << ans << "\n";
	}
}