#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;
template <typename T>
struct binary_indexed_tree{
	int N;
	vector<T> BIT;
	binary_indexed_tree(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		BIT = vector<T>(N + 1, 0);
	}
	void add(int i, T x){
		i++;
		while (i <= N){
			BIT[i] += x;
			i += i & -i;
		}
	}
	T sum(int i){
		T ans = 0;
		while (i > 0){
			ans += BIT[i];
			i -= i & -i;
		}
		return ans;
	}
	T sum(int L, int R){
		return sum(R) - sum(L);
	}
	T all(){
		return BIT[0];
	}
};
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];
    X[i]--;
  }
  vector<int> c = Y;
  c.push_back(0);
  sort(c.begin(), c.end());
  c.erase(unique(c.begin(), c.end()), c.end());
  int cnt = c.size();
  binary_indexed_tree<long long> Acnt(cnt), Bcnt(cnt);
  binary_indexed_tree<long long> Asum(cnt), Bsum(cnt);
  Acnt.add(0, N);
  Bcnt.add(0, M);
  vector<int> a(N, 0), b(M, 0);
  long long ans = 0;
  for (int i = 0; i < Q; i++){
    if (T[i] == 1){
      int curr_id = lower_bound(c.begin(), c.end(), a[X[i]]) - c.begin();
      int nxt_id = lower_bound(c.begin(), c.end(), Y[i]) - c.begin();
      ans -= Bsum.sum(curr_id, nxt_id);
      ans -= Bcnt.sum(0, curr_id) * a[X[i]];
      ans += Bcnt.sum(0, nxt_id) * Y[i];
      Acnt.add(curr_id, -1);
      Asum.add(curr_id, -a[X[i]]);
      Acnt.add(nxt_id, 1);
      Asum.add(nxt_id, Y[i]);
      a[X[i]] = Y[i];
    }
    if (T[i] == 2){
      int curr_id = lower_bound(c.begin(), c.end(), b[X[i]]) - c.begin();
      int nxt_id = lower_bound(c.begin(), c.end(), Y[i]) - c.begin();
      ans -= Asum.sum(curr_id + 1, nxt_id + 1);
      ans -= Acnt.sum(0, curr_id + 1) * b[X[i]];
      ans += Acnt.sum(0, nxt_id + 1) * Y[i];
      Bcnt.add(curr_id, -1);
      Bsum.add(curr_id, -b[X[i]]);
      Bcnt.add(nxt_id, 1);
      Bsum.add(nxt_id, Y[i]);
      b[X[i]] = Y[i];
    }
    cout << ans << endl;
  }
}