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