// Jai Shree Ram  
  
#include<bits/stdc++.h>
using namespace std;


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
#define ook order_of_key
#define fbo find_by_order

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC



template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int N=1e9+5;
const int M=1e7;



struct node{	
	int l;int r;
	int val;
	int cnt;
}t[M];
int cnt=0;

int n;

void extend(int v){
	if(t[v].l==0){
		t[v].l=++cnt;
		t[v].r=++cnt;
	}
}

void pushup(int v){
	t[v].val = t[t[v].l].val + t[t[v].r].val;
	t[v].cnt = t[t[v].l].cnt + t[t[v].r].cnt;
}	

void update(int v,int l,int r,pii val,int tl=0,int tr=1e9){
	if(tl>r || l>tr)return;
	if(l<=tl && tr<=r){
		assert(tl == tr);
		t[v].val += val.x;
		t[v].cnt += val.y;
		return;
	}
	extend(v);
	int mid=(tl+tr)/2;
	update(t[v].l,l,r,val,tl,mid);
	update(t[v].r,l,r,val,mid+1,tr);
	pushup(v);
}

pii query(int v,int l,int r,int tl=0,int tr=1e9){
	if(tl>r || l>tr)return {0,0};
	if(l<=tl && tr<=r){
		return {t[v].val,t[v].cnt}; 
	}
	int mid=(tl+tr)/2;
	extend(v);
	pii a =query(t[v].l,l,r,tl,mid);
	pii b =query(t[v].r,l,r,mid+1,tr);
	return {a.x+b.x,a.y+b.y};
}




int solve(){
		int n,m,q; cin >> n >> m >> q;

		int ans = 0;
		int roota = ++cnt;
		int rootb = ++cnt;

		vector<int>v1(n+1),v2(m+1);
		update(roota,0,0,{0,n});
		update(rootb,0,0,{0,m});
		
		rep(i,0,q){
			int t; cin >> t;
			int x,y; cin >> x >> y;
			if(t == 1){
				if(y > v1[x]){
					auto s = query(rootb,0,y);
					ans += s.y*y;
					s = query(rootb,v1[x]+1,y);
					ans -= s.x;
					s = query(rootb,0,v1[x]);
					ans -= v1[x]*s.y;
				}
				else if(y < v1[x]){
					auto s = query(rootb,0,v1[x]);
					ans -= s.y*v1[x];
					s = query(rootb,0,y);
					ans += s.y*y;
					s = query(rootb,y+1,v1[x]);
					ans += s.x;
				}	
				update(roota,v1[x],v1[x],{-v1[x],-1});
				update(roota,y,y,{y,1});
				v1[x] = y;
			}
			else{
				if(y > v2[x]){
					auto s = query(roota,0,y-1);
					ans += s.y*y;
					s = query(roota,0,v2[x]-1);
					ans -= s.y*v2[x];
					s = query(roota,v2[x],y-1);
					ans -= s.x;
				}
				else if(y < v2[x]){
					auto s = query(roota,0,v2[x]-1);
					ans -= s.y*v2[x];
					s = query(roota,0,y-1);
					ans += s.y*y;
					s = query(roota,y,v2[x]-1);
					ans += s.x;
				}
				update(rootb,v2[x],v2[x],{-v2[x],-1});
				update(rootb,y,y,{y,1});
				v2[x] = y;
			}	
			cout << ans << endl;
		}
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1<<19;
int N, M, Q;
ll a[200005], b[200005];
vector<ll> v;
vector<pair<int, ll>> tree_a(MAXN), tree_b(MAXN);	// cnt, sum
int qt[200005], qx[200005], qy[200005];

void update(vector<pair<int, ll>> &tree, int node, int s, int e, int idx, int d) {
	if(idx < s || idx > e) return ;
	if(s == idx && idx == e) {
		tree[node].first += d;
		tree[node].second = tree[node].first * v[idx];
		return ;
	}
	int n1 = node << 1, n2 = node << 1 | 1;
	int mid = s + e >> 1;
	update(tree, n1, s, mid, idx, d);
	update(tree, n2, mid+1, e, idx, d);
	tree[node].first = tree[n1].first + tree[n2].first;
	tree[node].second = tree[n1].second + tree[n2].second;
}

pair<int, ll> query(vector<pair<int, ll>> &tree, int node, int s, int e, int l, int r) {
	if(l > e || r < s) return make_pair(0, 0);
	if(l <= s && e <= r) return tree[node];
	int n1 = node << 1, n2 = node << 1 | 1;
	int mid = s + e >> 1;
	pair<int, ll> p1 = query(tree, n1, s, mid, l, r);
	pair<int, ll> p2 = query(tree, n2, mid+1, e, l, r);
	return make_pair(p1.first + p2.first, p1.second + p2.second);
}

int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	cin >> N >> M >> Q;
	v.push_back(0);
	for(int i=0;i<Q;++i) {
		cin >> qt[i] >> qx[i] >> qy[i];
		v.push_back(qy[i]);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	ll sum = 0;
	ll a_sum = 0, b_sum = 0;
	update(tree_a, 1, 0, v.size()-1, 0, N);
	update(tree_b, 1, 0, v.size()-1, 0, M);
	for(int i=0;i<Q;++i) {
		int idx = qx[i];
		ll val = qy[i];
		int q_idx = lower_bound(v.begin(), v.end(), val) - v.begin();
		if(qt[i] == 1) {
			int cur_idx = lower_bound(v.begin(), v.end(), a[idx]) - v.begin();
			pair<int, ll> pre = query(tree_b, 1, 0, v.size()-1, 0, cur_idx);
			int n = pre.first;
			ll pre_sum = n*a[idx] + b_sum - pre.second;
			a_sum -= a[idx];
			sum -= pre_sum;
			update(tree_a, 1, 0, v.size()-1, cur_idx, -1);
			a[idx] = val;
			a_sum += val;
			update(tree_a, 1, 0, v.size()-1, q_idx, 1);
			pair<int, ll> p = query(tree_b, 1, 0, v.size()-1, 0, q_idx);
			sum += p.first * a[idx] + b_sum - p.second;
		}
		else {
			int cur_idx = lower_bound(v.begin(), v.end(), b[idx]) - v.begin();
			pair<int, ll> pre = query(tree_a, 1, 0, v.size()-1, 0, cur_idx);
			int n = pre.first;
			ll pre_sum = n*b[idx] + a_sum - pre.second;
			b_sum -= b[idx];
			sum -= pre_sum;
			update(tree_b, 1, 0, v.size()-1, cur_idx, -1);
			b[idx] = val;
			b_sum += val;
			update(tree_b, 1, 0, v.size()-1, q_idx, 1);
			pair<int, ll> p = query(tree_a, 1, 0, v.size()-1, 0, q_idx);
			sum += p.first * b[idx] + a_sum - p.second;
		}
		cout << sum << '\n';
	}
	return 0;
}