#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;
const int N = 2e5 + 5;
using ll = long long;
int n, m, q, t[N], x[N], y[N], dic[N], L;
int a[N], b[N];
ll d[4][N];
void add(int idx, int x, int v) {
    for(int i = x; i <= L; i += i & -i) d[idx][i] += v;
}
ll get(int idx, int x) {
    ll res = 0;
    for(int i = x; i; i -= i & -i) res += d[idx][i];
    return res;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> q;
    for(int i = 1; i <= q; i++) {
        cin >> t[i] >> x[i] >> y[i];
        dic[i] = y[i];
    }
    dic[q + 1] = 0;
    sort(dic + 1, dic + q + 2);
    L = unique(dic + 1, dic + q + 2) - dic - 1;
    add(0, 1, n);
    add(2, 1, m);
    // for(int j = 0; j < 4; j++) {
    //     for(int i = 1; i <= L; i++) cout << get(j, i) - get(j, i - 1) << " ";
    //     cout << endl;
    // }
    // cout << endl;
    ll ans = 0;
    for(int i = 1; i <= q; i++) {
        int np = lower_bound(dic + 1, dic + L + 1, y[i]) - dic;
        // cout << t[i] << " " << x[i] << " " << y[i] << " " << np << endl;
        if(t[i] == 1) {
            int p = lower_bound(dic + 1, dic + L + 1, a[x[i]]) - dic; 
            // for(int i = 1; i <= L; i++) cout << get(2, i) << endl;
            // cout << np << " " << p << endl;
            ans += get(2, np) * y[i] -  get(2, p) * a[x[i]];
            ans -= get(3, np) - get(3, p);
            add(0, p, -1);
            add(0, np, 1);
            add(1, p, -a[x[i]]);
            add(1, np, y[i]);
            a[x[i]] = y[i];
        } else {
            int p = lower_bound(dic + 1, dic + L + 1, b[x[i]]) - dic;
            ans += get(0, np - 1) * y[i] - get(0, p - 1) * b[x[i]];
            ans -= get(1, np - 1) - get(1, p - 1);
            // cout << get(0, np - 1) * y[i] - get(0, p - 1) * b[x[i]] << " " << get(1, np - 1) - get(1, p - 1) << endl;
            add(2, p, -1);
            add(2, np, 1);
            add(3, p, -b[x[i]]);
            add(3, np, y[i]);
            b[x[i]] = y[i];
        }
        cout << ans << endl;
        // for(int j = 0; j < 4; j++) {
        //     for(int i = 1; i <= L; i++) cout << get(j, i) - get(j, i - 1) << " ";
        //     cout << endl;
        // }
        // cout << endl;
    }
    return 0;
}