#include <bits/stdc++.h>
#ifdef mlocal
#include "./Competitive-Code-Library/snippets/prettyprint.h"
#endif
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
#define endl '\n'

// Ask for sum 1 -> n for full (one based indexing)
class BIT {
private: vector<ll> tree; int n;
	int LSOne(int x) {
		return x&(-x);
	}

public:
	BIT(int x) {
		n = x;
		tree.resize(n+1);
	}
	ll sum(int a) {
		ll sum = 0;
		for (; a > 0; a -= LSOne(a)) sum += tree[a];
		return sum;
	}
	ll sum(int a, int b) {
		return sum(b) - (a == 1 ? 0 : sum(a-1));
	}
	void update(int p, ll v) {
		for (; p < n+1; p += LSOne(p)) tree[p] += v;
	}
};



int main() {
#ifdef mlocal
	freopen("test.in", "r", stdin);
#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, q; cin >> n >> m >> q;
	vector<array<int, 3>> qrs(q);
	map<int, int> mp;
	for_(i, 0, q) {
		for_(j, 0, 3) cin >> qrs[i][j];
		qrs[i][1] -= 1;
		mp[qrs[i][2]] = 1;
	}
	
	int pt = 3;
	for (auto &i: mp) mp[i.first] = pt++;
	vector<BIT> tree(2, BIT(pt+1)), ctTree(2, BIT(pt+1));
	
	ll ans = 0;
	vi a(n, 2), b(m, 2);
	ctTree[0].update(2, n); ctTree[1].update(2, m);
	
	vector<ll> rawa(n, 0), rawb(m, 0);
	for_(i, 0, q) {
		ll raw = qrs[i][2];
		qrs[i][2] = mp[qrs[i][2]];
		if (qrs[i][0] == 1) {
			if (a[qrs[i][1]] < qrs[i][2]) {
				ans -= tree[1].sum(a[qrs[i][1]]+1, qrs[i][2]);
			} else if (a[qrs[i][1]] > qrs[i][2]) {
				ans += tree[1].sum(qrs[i][2]+1, a[qrs[i][1]]);
			}
			
			ans -= ctTree[1].sum(1, a[qrs[i][1]]) * rawa[qrs[i][1]];
			
			ctTree[0].update(a[qrs[i][1]], -1);
			tree[0].update(a[qrs[i][1]], -rawa[qrs[i][1]]);
			
			a[qrs[i][1]] = qrs[i][2];
			rawa[qrs[i][1]] = raw;
			
			ctTree[0].update(a[qrs[i][1]], 1);
			tree[0].update(a[qrs[i][1]], rawa[qrs[i][1]]);
			
			ans += ctTree[1].sum(1, a[qrs[i][1]]) * rawa[qrs[i][1]];
		} else {
			if (b[qrs[i][1]] < qrs[i][2]) {
				ans -= tree[0].sum(b[qrs[i][1]], qrs[i][2]-1);
			} else if (b[qrs[i][1]] > qrs[i][2]) {
				ans += tree[0].sum(qrs[i][2], b[qrs[i][1]]-1);
			}
			
			ans -= ctTree[0].sum(1, b[qrs[i][1]]-1) * rawb[qrs[i][1]];
			
			ctTree[1].update(b[qrs[i][1]], -1);
			tree[1].update(b[qrs[i][1]], -rawb[qrs[i][1]]);
			
			b[qrs[i][1]] = qrs[i][2];
			rawb[qrs[i][1]] = raw;
			
			ctTree[1].update(b[qrs[i][1]], 1);
			tree[1].update(b[qrs[i][1]], rawb[qrs[i][1]]);
			
			ans += ctTree[0].sum(1, b[qrs[i][1]]-1) * rawb[qrs[i][1]];
		}
		
		
		cout << ans << endl;
	}
	
}


#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>

template <class E> struct FenwickTree {
    int _n;
    std::vector<E> data;

    FenwickTree(int n) : _n(n), data(n) { }

    void add(int p, E x) {
        ++p;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }
    E sum(int r) const {
        E s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
    E sum(int l, int r) const {
        return sum(r) - sum(l);
    }
};

long long proc(
    std::vector<int>             &cur,
    int                          x,
    int                          y,
    FenwickTree<int>             &ftcnt0,
    FenwickTree<long long>       &ftsum0,
    const FenwickTree<int>       &ftcnt1,
    const FenwickTree<long long> &ftsum1,
    const std::vector<int>       &arr)
{
    int v = cur[x];
    long long dem = (long long)ftcnt1.sum(0, v) * arr[v];
    long long cre = (long long)ftcnt1.sum(0, y) * arr[y];
    long long adj = (long long)ftsum1.sum(y, v);

    ftsum0.add(v, -arr[v]);
    ftcnt0.add(v, -1);
    cur[x] = y;
    ftsum0.add(y, arr[y]);
    ftcnt0.add(y, 1);

    return cre + adj - dem;
}

int main(int argc, char **argv)
{
    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);
    std::set<int> s = { 0 };
    std::vector<int> ta(q), xa(q), ya(q);

    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &ta[i], &xa[i], &ya[i]);
        xa[i]--;
        s.insert(ya[i]);
    }
    int ll = s.size();
    std::vector<int> arr(ll);
    std::map<int, int> map;
    int ii = 0;
    for (auto &k : s) {
        arr[ii] = k;
        map.emplace(k, ii);
        ++ii;
    }

    FenwickTree<long long> ftsuma(ll);
    FenwickTree<long long> ftsumb(ll);
    FenwickTree<int>       ftcnta(ll);
    FenwickTree<int>       ftcntb(ll);
    std::vector<int> cura(n);
    std::vector<int> curb(m);
    ftcnta.add(0, n);
    ftcntb.add(0, m);
    long long sum = 0;

    for (int i = 0; i < q; i++) {
        int cy = map[ya[i]];
        sum += (ta[i] == 1) ? proc(cura, xa[i], cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                            : proc(curb, xa[i], cy, ftcntb, ftsumb, ftcnta, ftsuma, arr); 
        printf("%lld\n", sum);
    }
    return 0;
}