#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
	x=0;char ch=getchar();bool f=false;
	while(!isdigit(ch)){if(ch=='-'){f=true;}ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return ;
}
template <typename T>
inline void write(T x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10^48);
	return ;
}
#define ll long long
const int N=2e5+5,M=1e8;
int n,m,q;
ll a[N],b[N];
struct SGTree{
	int cur,root;
	ll sum[N*80];
	int num[N*80],ls[N*80],rs[N*80];
	void Modify(int &x,int l,int r,int pos,int v,int tp){
		if(!x) x=++cur;
		int mid=l+r>>1;sum[x]+=v*tp;num[x]+=tp;
		if(l==r) return ;
		if(pos<=mid) Modify(ls[x],l,mid,pos,v,tp);
		else Modify(rs[x],mid+1,r,pos,v,tp);
		return ;
	}
	ll QuerySum(int x,int l,int r,int ql,int qr){
		if(ql>qr||!x) return 0;
		if(ql<=l&&r<=qr) return sum[x];
		int mid=l+r>>1;ll res=0;
		if(ql<=mid) res+=QuerySum(ls[x],l,mid,ql,qr);
		if(qr>mid) res+=QuerySum(rs[x],mid+1,r,ql,qr);
		return res;
	}
	int QueryNum(int x,int l,int r,int ql,int qr){
		if(ql>qr||!x) return 0;
		if(ql<=l&&r<=qr) return num[x];
		int mid=l+r>>1,res=0;
		if(ql<=mid) res+=QueryNum(ls[x],l,mid,ql,qr);
		if(qr>mid) res+=QueryNum(rs[x],mid+1,r,ql,qr);
		return res;
	}
}t1,t2;
ll Ans;
int main(){
	read(n),read(m),read(q);
	for(int i=1;i<=n;i++) t1.Modify(t1.root,0,M,a[i],a[i],1);
	for(int i=1;i<=m;i++) t2.Modify(t2.root,0,M,b[i],b[i],1);
//	for(int i=1;i<=n;i++){
//		Ans+=1ll*t2.QueryNum(t2.root,0,M,1,a[i])*a[i];
//		Ans+=1ll*t2.QuerySum(t2.root,0,M,a[i]+1,M);
//	}
	for(int i=1;i<=q;i++){
		int op,pos;ll v;
		read(op),read(pos),read(v);
		if(op==1){
			Ans-=1ll*t2.QueryNum(t2.root,0,M,0,a[pos])*a[pos];
			Ans-=1ll*t2.QuerySum(t2.root,0,M,a[pos]+1,M);
			t1.Modify(t1.root,0,M,a[pos],a[pos],-1);
			
			a[pos]=v;
			Ans+=1ll*t2.QueryNum(t2.root,0,M,0,a[pos])*a[pos];
			Ans+=1ll*t2.QuerySum(t2.root,0,M,a[pos]+1,M);
			t1.Modify(t1.root,0,M,a[pos],a[pos],1);
		}
		else{
			Ans-=1ll*t1.QueryNum(t1.root,0,M,0,b[pos])*b[pos];
			Ans-=1ll*t1.QuerySum(t1.root,0,M,b[pos]+1,M);
			t2.Modify(t2.root,0,M,b[pos],b[pos],-1);
			b[pos]=v;
			Ans+=1ll*t1.QueryNum(t1.root,0,M,0,b[pos])*b[pos];
			Ans+=1ll*t1.QuerySum(t1.root,0,M,b[pos]+1,M);
			t2.Modify(t2.root,0,M,b[pos],b[pos],1);
		}
		write(Ans),putchar('\n');
	}
	return 0;
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

template <typename T>
class fenwick {
private:
	vector <T> sum;
	vector <T> cnt;
	int size;
	
public:
	fenwick(int _n) : size(_n) {
		sum.assign(size + 1, 0);
		cnt.assign(size + 1, 0);
	}
	
	void upd_sum(int i, T v) {
		for(; i <= size; i += i&-i) {
			sum[i] += v;
		}
	}

	void upd_cnt(int i, T v) {
		for(; i <= size; i += i&-i) {
			cnt[i] += v;
		}
	}
	
	T qry_sum(int i) {
		T curr = 0;
		for(; i; i -= i&-i) {
			curr += sum[i];
		}
		return curr;
	}

	T qry_cnt(int i) {
		T curr = 0;
		for(; i; i -= i&-i) {
			curr += cnt[i];
		}
		return curr;
	}
};

const int maxN = 2e5 + 5;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m, q;
	cin >> n >> m >> q;

	vector <tuple<int, int, int>> queries;
	vector <int> order = {0};

	for(int i = 0; i < q; i++) {
		int t, x, y;
		cin >> t >> x >> y; --x;
		queries.emplace_back(t, x, y);
		order.push_back(y);
	}
	order.erase(unique(order.begin(), order.end()), order.end());
	sort(order.begin(), order.end());

	vector <int> A(n, 0), B(m, 0);
	fenwick <ll> ft_A(maxN), ft_B(maxN);
	ft_A.upd_cnt(1, n); ft_B.upd_cnt(1, m);

	ll ans = 0;
	for(auto &[t, x, y] : queries) {
		int pos = lower_bound(order.begin(), order.end(), y) - order.begin() + 1;
		assert(order[pos - 1] == y);

		if(t == 1) {
			int prev = lower_bound(order.begin(), order.end(), A[x]) - order.begin() + 1;
			assert(order[prev - 1] == A[x]);

			ans -= 1LL * ft_B.qry_cnt(prev - 1) * A[x];
			ans -= (ft_B.qry_sum(pos - 1) - ft_B.qry_sum(prev - 1));
			ans += 1LL * ft_B.qry_cnt(pos - 1) * y;

			ft_A.upd_cnt(prev, -1); ft_A.upd_cnt(pos, 1);
			ft_A.upd_sum(prev, -A[x]); ft_A.upd_sum(pos, y);
			A[x] = y;
		}
		else {
			int prev = lower_bound(order.begin(), order.end(), B[x]) - order.begin() + 1;
			assert(order[prev - 1] == B[x]);

			ans -= 1LL * ft_A.qry_cnt(prev - 1) * B[x];
			ans -= (ft_A.qry_sum(pos - 1) - ft_A.qry_sum(prev - 1));
			ans += 1LL * ft_A.qry_cnt(pos - 1) * y;
			
			ft_B.upd_cnt(prev, -1); ft_B.upd_cnt(pos, 1);
			ft_B.upd_sum(prev, -B[x]); ft_B.upd_sum(pos, y);
			B[x] = y;
		}
		cout << ans << '\n';
	}
}