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

#include<bits/stdc++.h>
#include<bits/extc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t){
	while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<": "; for(auto i:x) cerr<<i<<" "; cerr<<endl;}}
#define debugr(l,r,x) {{cerr<<#x<<": "; for(int i=l;i<=r;i++) cerr<<x<<" "; cerr<<endl;}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debugr(l,r,x)
#define cerr while(0) cerr
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef __int128 INT;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define priority_queue std::priority_queue
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

struct Node{
	typedef ll T;
	static constexpr T unset = INT_MIN, unit=0;
	T f(T a, T b) { return max(a, b); }
	T mset=unset, madd=0, val=unit; int lo, hi;
	Node *l=0, *r=0;
	Node(int lo, int hi): lo(lo), hi(hi){
		if(lo<hi){
			int mid=(lo+hi)/2;
			l=new Node(lo, mid); r=new Node(mid+1, hi);
		}
	}
	T query(int L, int R){
		push();
		if(R<lo || hi<L) return unit; //sentinel
		if(L<=lo && hi<=R) return val;
		return f(l->query(L, R), r->query(L, R));
	}
	void set(int L, int R, T x, int t=1){
		push();
		if(R<lo || hi<L) return;
		if(L<=lo && hi<=R){
			(t==1 ? mset : madd)=x;
			push(); return;
		}
		l->set(L, R, x, t), r->set(L, R, x, t);
		val=f(l->val, r->val);
	}
	void add(int L, int R, T x) { return set(L, R, x, 0); }
	void push(){
		mset!=unset ? val=mset : val+=madd; //multiply (hi-lo+1) for sum queries
		if(l){ //if parent, push down
			if(mset!=unset){
				l->mset=r->mset=mset;
				l->madd=r->madd=0;
			}
			else if(madd){
				l->mset!=unset ? l->mset+=madd : l->madd+=madd;
				r->mset!=unset ? r->mset+=madd : r->madd+=madd;
			}
		}
		mset=unset, madd=0;
	}
};

map<int, int> mp;
ordered_set os[3];
ll a[3][200006];
ll cnt[3];
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, q;
	cin>>n>>m>>q;
	vector<pair<int, pii>> queries;
	set<int> s;
	s.insert(0);
	for(int i=1; i<=q; i++){
		int t, x, y;
		cin>>t>>x>>y;
		queries.push_back({t, {x, y}});
		s.insert(y);
	}
	int cur=1;
	for(int i: s) mp[i]=cur++;
	ll ans = 0;
	Node **tree = new Node*[3];
	for(int i=1;i<3;i++) tree[i] = new Node(0, 200005);

	auto sum = [&](int t, ll v){
		ll ans = cnt[t];
		ans -= tree[t]->query(mp[v], mp[v]);
		ans += os[t].order_of_key(v+1) * v;
		return ans;
	};

	for(int i=0; i<n; i++) os[1].insert(0);
	for(int j=0; j<m; j++) os[2].insert(0);
	//debugv(os[1]);
	//debugv(os[2]);
	for(auto [t, p]: queries){
		auto [x, y] = p;
		ans += sum(3-t, y) - sum(3-t, a[t][x]);
		cout<<ans<<'\n';
		cnt[t]+=y-a[t][x];
		tree[t]->add(mp[y], 200004, y);
		tree[t]->add(mp[a[t][x]], 200004, -a[t][x]);
		os[t].erase(os[t].lower_bound(a[t][x]-1));
		os[t].insert(y);
		a[t][x] = y;
		debugv(os[1]);
		debugv(os[2]);
	}
}