#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


struct TrieNode{
	int n = 0;
	long long sum = 0;
	TrieNode* l = nullptr, * r = nullptr;
};

class Trie {
public:
	Trie() { root = new TrieNode(); }

	void insert(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n++;
			t->sum += x;
			if (x >> i &1) {
				if (t->r == nullptr) t->r = new TrieNode;
				t = t->r;
			}
			else {
				if (t->l == nullptr) t->l = new TrieNode;
				t = t->l;
			}
		}
		t->n++;
		t->sum += x;
	}

	void erase(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n--;
			t->sum -= x;
			if (x >> i & 1) {
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		t->n--;
		t->sum -= x;
	}

	pair<int, long long> query(int x) const{
		pair<int, long long > ret(0, 0);
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			if (t == nullptr)break;
			if (x >> i & 1) {
				if (t->l) {
					ret.first += t->l->n;
					ret.second += t->l->sum;
				}
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return ret;
	}
private:
	TrieNode* root;
};



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, m, q;
	cin >> n >> m >> q;

	vector<int> a(n, 0), b(m, 0);

	Trie ta, tb;
	rep(i, n) ta.insert(0);
	rep(i, m)tb.insert(0);

	long long ans = 0;
	rep(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		x--;

		if (t == 1) {
			auto p = tb.query(a[x]);
			ans -= (long long)p.first * a[x];
			ans += p.second;
		
			p = tb.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			ta.erase(a[x]);
			ta.insert(y);
			a[x] = y;
		}
		else {
			auto p = ta.query(b[x]);
			ans -= (long long)p.first * b[x];
			ans += p.second;
			
			p = ta.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			tb.erase(b[x]);
			tb.insert(y);
			b[x] = y;
		}
		cout << ans << endl;
	}


	return 0;
}

#include<bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-20
#define fi first
#define se second
using namespace std;
using cd = complex<double>;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdd;
struct ppp{ll t,x,y;}c[200005];
ll a[200005],b[200005],N=500000;
ll tree[500005][2],num[500005][2];
void add(ll x,ll k,ll t){
    while(x<N){
        tree[x][t]+=k;
        x+=x&(-x);
    }
}
ll query(ll x,ll t){
    ll res=0;
    while(x){
        res+=tree[x][t];
        x-=x&(-x);
    }return res;
}
void up(ll x,ll k,ll t){
    while(x<N){
        num[x][t]+=k;
        x+=x&(-x);
    }
}
ll cal(ll x,ll t){
    ll res=0;
    while(x){
        res+=num[x][t];
        x-=x&(-x);
    }return res;
}
int main(){
    ll n,m,q,ans=0;
    cin>>n>>m>>q;
    set<ll> s;vector<ll> p;
    s.insert(0);
    for(ll i=1;i<=q;i++){
        cin>>c[i].t>>c[i].x>>c[i].y;
        s.insert(c[i].y);
    }
    p.push_back(-2e18);
    for(auto i:s){
        p.push_back(i);
    }
    ll st=lower_bound(p.begin(),p.end(),(ll)0)-p.begin();
    up(st,n,0);up(st,m,1);
    for(ll i=1;i<=q;i++){
        if(c[i].t==2){
            ll v=b[c[i].x],y=c[i].y;
            ll l=lower_bound(p.begin(),p.end(),v)-p.begin();
            ll pn=cal(l,0),pv=pn*v+query(N,0)-query(l,0);
            ans-=pv;up(l,-1,1);add(l,-v,1);
            l=lower_bound(p.begin(),p.end(),y)-p.begin();
            pn=cal(l,0),pv=pn*y+query(N,0)-query(l,0);
            ans+=pv;up(l,1,1);add(l,y,1);b[c[i].x]=y;
        }
        else{
            ll v=a[c[i].x],y=c[i].y;
            ll l=lower_bound(p.begin(),p.end(),v)-p.begin();
            ll pn=cal(l,1),pv=pn*v+query(N,1)-query(l,1);
            ans-=pv;up(l,-1,0);add(l,-v,0);
            l=lower_bound(p.begin(),p.end(),y)-p.begin();
            pn=cal(l,1),pv=pn*y+query(N,1)-query(l,1);
            ans+=pv;up(l,1,0);add(l,y,0);a[c[i].x]=y;
        }
        cout<<ans<<endl;
    }
}
