#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;

//const int mod = 1000000007;
//const int mod = 998244353;

class BIT {
public:
	BIT(int n) : a(n) {}

	void add(int p, long long num)
	{
		while (p < a.size()) {
			a[p] += num;
			p |= p + 1;
		}
	}

	/* i から j までの和 [i, j] */
	long long sum(int i, int j)
	{
		long long s = 0, t = 0;
		i--;
		while (i >= 0) {
			s += a[i];
			i = (i & (i + 1)) - 1;
		}
		while (j >= 0) {
			t += a[j];
			j = (j & (j + 1)) - 1;
		}
		return t - s;
	}

private:
	vector<long long> a;
};

vector<int> compress_num, compressed_num;
int find_comp(int x)
{
	return lower_bound(compress_num.begin(), compress_num.end(), x) - compress_num.begin();
}

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	vector<long long> t(q), x(q), y(q);
	for (int i = 0; i < q; i++) {
		cin >> t[i] >> x[i] >> y[i];
		x[i]--;
	}

	for (int i = 0; i < q; i++) {
		compress_num.emplace_back(y[i]);
	}
	compress_num.emplace_back(0);
	sort(compress_num.begin(), compress_num.end());
	compress_num.erase(unique(compress_num.begin(), compress_num.end()), compress_num.end());
	/*for (int i = 0; i < compress_num.size(); i++) {
		compressed_num[i] = lower_bound(compress_num.begin(), compress_num.end(),
			compress_num[i]) - compress_num.begin();
	}*/

	long long sum = 0;
	vector<int> a(n), b(m);
	BIT bita(q+10), bitb(q + 10);
	BIT numa(q+10), numb(q + 10);
	numa.add(0, n);
	numb.add(0, m);
	for (int i = 0; i < q; i++) {
		if (t[i] == 1) {
			sum -= bitb.sum(find_comp(a[x[i]]), q+5) + a[x[i]] * numb.sum(0, find_comp(a[x[i]]) - 1);
			bita.add(find_comp(a[x[i]]), -a[x[i]]);
			numa.add(find_comp(a[x[i]]), -1);
			a[x[i]] = y[i];
			numa.add(find_comp(a[x[i]]), 1);
			bita.add(find_comp(a[x[i]]), a[x[i]]);
			sum += bitb.sum(find_comp(a[x[i]]), q+5) + y[i] * numb.sum(0, find_comp(a[x[i]]) - 1);
			cout << sum << endl;
		} else {
			sum -= bita.sum(find_comp(b[x[i]]), q + 5) + b[x[i]] * numa.sum(0, find_comp(b[x[i]]) - 1);
			bitb.add(find_comp(b[x[i]]), -b[x[i]]);
			numb.add(find_comp(b[x[i]]), -1);
			b[x[i]] = y[i];
			numb.add(find_comp(b[x[i]]), 1);
			bitb.add(find_comp(b[x[i]]), b[x[i]]);
			sum += bita.sum(find_comp(b[x[i]]), q + 5) + y[i] * numa.sum(0, find_comp(b[x[i]]) - 1);
			cout << sum << endl;
		}
		/*for (int j = 0; j < n; j++) {
			cout << a[j] << " ";
		}
		cout << endl;
		for (int j = 0; j < m; j++) {
			cout << b[j] << " ";
		}
		cout << endl;*/
	}

	return 0;
}
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long> 
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int n, m, q, t[MAX_N], x[MAX_N], y[MAX_N], memo[MAX_N][2];
map<int, int> ma;
vector<ll> ans;

P bit[MAX_N + 2][2];

P sum(int i, int j) {
    P s = P(0, 0);
    while (i > 0) {
        s.fi += bit[i][j].fi;
        s.se += bit[i][j].se;
        i -= i & -i;
    }
    return s;
}

void add(int i, int j, int x, int y) {
    while (i <= q + 1) {
        bit[i][j].fi += x;
        bit[i][j].se += y;
        i += i & -i;
    }
}

int main() {
    ci3(n, m, q);
    rep(i, q) {
        ci3(t[i], x[i], y[i]);
        ma.ep(y[i], 0);
    }
    ma.ep(0, 0);
    int cnt = 0;
    for (auto &i: ma) i.se = ++cnt;
    ans.epb(0);
    rep(i, n) add(1, 0, 1, 0);
    rep(i, m) add(1, 1, 1, 0);
    rep(i, q) {
        int old_y = memo[x[i] - 1][t[i] - 1];
        add(ma[y[i]], t[i] - 1, 1, y[i]);
        add(ma[old_y], t[i] - 1, -1, -old_y);
        P p1 = sum(ma[y[i]] - t[i] % 2, t[i] % 2);
        P p2 = sum(ma[old_y] - t[i] % 2, t[i] % 2);
        ll tmp = ans.back();
        tmp += scll(p1.fi) * y[i] - scll(p2.fi) * old_y; 
        tmp += p2.se - p1.se;
        ans.epb(tmp);
        memo[x[i] - 1][t[i] - 1] = y[i];
    }
    rep(i, q) co(ans[i + 1]);
    return 0;
}
