#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;
}
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#ifdef local
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define pary(a...) danb(#a, a)
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
    int cnt = sizeof...(T);
    ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
template <typename T> void danb(const char *s, T L, T R) {
    std::cerr << "\033[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L)
        std::cerr << (f++ ? ", " : "") << *L;
    std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back
#define get_pos(u,x) int(lower_bound(all(u),x)-begin(u))

using namespace std;
using ll = int_fast64_t;
const int inf = 1e9;
const int mod = 1000000007;
const ll INF = 1e18;
const int maxn = 200025;

struct Fenwick {
    ll b[maxn];
    void add(int p, int d) {
        for (++p; p < maxn; p += p & -p)
            b[p] += d;
    }
    ll query(int p) {
        ll r = 0;
        for (++p; p > 0; p -= p & -p)
            r += b[p];
        return r;
    }
} cnt_a, cnt_b, sum_a, sum_b;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<tuple<int,int,int>> Qs(q);
    vector<int> u;
    u.pb(0);
    for (auto &[t, x, y]: Qs) cin >> t >> x >> y, u.pb(y), --x;
    sort(all(u)), u.erase(unique(all(u)), u.end());
    vector<int> a(n), b(m);

    auto calc = [&](int val, Fenwick &cnt, Fenwick &sum) {
        int pos = get_pos(u, val);
        return val * cnt.query(pos - 1) + (sum.query(maxn - 2) - sum.query(pos - 1));
    };
    ll ans = 0;
    cnt_a.add(get_pos(u, 0), n);
    cnt_b.add(get_pos(u, 0), m);
    for (auto [t, x, y]: Qs) {
        if (t == 1) {
            cnt_a.add(get_pos(u, a[x]), -1);
            sum_a.add(get_pos(u, a[x]), -a[x]);
            ans -= calc(a[x], cnt_b, sum_b);
            a[x] = y;
            ans += calc(a[x], cnt_b, sum_b);
            cnt_a.add(get_pos(u, a[x]), 1);
            sum_a.add(get_pos(u, a[x]), a[x]);
        } else {
            cnt_b.add(get_pos(u, b[x]), -1);
            sum_b.add(get_pos(u, b[x]), -b[x]);
            ans -= calc(b[x], cnt_a, sum_a);
            b[x] = y;
            ans += calc(b[x], cnt_a, sum_a);
            cnt_b.add(get_pos(u, b[x]), 1);
            sum_b.add(get_pos(u, b[x]), b[x]);
        }
        cout << ans << '\n';
    }
}
