#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;

struct BIT {
    vector<int64_t> t;
    BIT (int n) : t(n, 0) {}
    void update(int i, int64_t x) {
        for (; i < int(t.size()); i |= i + 1) {
            t[i] += x;
        }
    }
    int64_t query(int i) {
        int64_t res = 0;
        for (; i > 0; i &= i - 1) {
            res += t[i - 1];
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n[2], q;
    cin >> n[0] >> n[1] >> q;
    vector<array<int, 3>> queries(q);
    vector<int> nums(1, 0);
    nums.reserve(q + 1);
    for (auto& it : queries) {
        cin >> it[0] >> it[1] >> it[2];
        it[0]--;
        it[1]--;
        nums.push_back(it[2]);
    }
    sort(nums.begin(), nums.end());
    nums.erase(unique(nums.begin(), nums.end()), nums.end());

    int sz = nums.size();
    int64_t ans = 0;
    vector<int> v[2];
    v[0].resize(n[0]);
    v[1].resize(n[1]);
    vector<BIT> cnt(2, BIT(sz)), sum(2, BIT(sz));
    cnt[0].update(0, n[0]);
    cnt[1].update(0, n[1]);
    for (auto qq : queries) {
        int a = qq[0], b = qq[0] ^ 1;
        int before = v[a][qq[1]];
        int id = lower_bound(nums.begin(), nums.end(), before) - nums.begin();
        ans -= int64_t(before) * cnt[b].query(id);
        ans += sum[b].query(id);
        int after = qq[2];
        int nid = lower_bound(nums.begin(), nums.end(), after) - nums.begin();
        ans -= sum[b].query(nid);
        ans += int64_t(after) * cnt[b].query(nid);
        cnt[a].update(id, -1);
        sum[a].update(id, -before);
        cnt[a].update(nid, 1);
        sum[a].update(nid, after);
        v[a][qq[1]] = after;
        cout << ans << '\n';
    }
    return 0;
}
