#include <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define PB push_back
#define REP(i, L, R) for (int i = L; i < (R); ++i)
#define SZ(x) (int)x.size()

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

vector<int> compress(vector<int> &y)
{
    vector<int> v(y);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i = 0; i < SZ(y); ++i)
    {
        y[i] = lower_bound(v.begin(), v.end(), y[i]) - v.begin();
    }

    return v;
}

struct bit
{
    int n;
    vector<ll> v;

    void init(int sz)
    {
        n = sz;
        v.assign(n + 1, 0);
    }

    // sum([0..i])
    ll prefix_sum(int i)
    {
        // internally we use 1-based index
        int _i = i + 1;
        ll s = 0LL;
        while (_i)
        {
            s += v[_i];
            _i -= (_i & -_i);
        }
        return s;
    }

    // sum([i..end])
    ll suffix_sum(int i)
    {
        if (i == 0)
        {
            return prefix_sum(n - 1);
        }

        return prefix_sum(n - 1) - prefix_sum(i - 1);
    }

    void incr(int i, ll a)
    {
        // internally we use 1-based indexing
        int _i = i + 1;
        while (_i <= n)
        {
            v[_i] += a;
            _i += (_i & -_i);
        }
    }
};

const int MAXN = 200005;
void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> t(q + 1), x(q + 1), y(q + 1, 0);
    vector<int> a(n, 0), b(m, 0);
    REP(i, 1, q + 1)
    {
        cin >> t[i] >> x[i] >> y[i];
        --x[i]; // 0-based index
    }

    auto vy = compress(y);
    // NOTE 1(coordinate compression): after compression, y is compressed to [0, q] and vy maps from a compressed y in [0,q] to its original value.

    // r1[i] = #i in b; r2[i] = sum of all i's in b.
    // c1[i] = #i in a; c2[i] = sum of all i's in a.
    bit r1, r2, c1, c2;
    r1.init(MAXN);
    r2.init(MAXN);
    c1.init(MAXN);
    c2.init(MAXN);
    // Initially, all b are 0
    r1.incr(0, m);
    // Initially, all a are 0
    c1.incr(0, n);

    ll ans = 0LL;
    REP(i, 1, q + 1)
    {
        if (t[i] == 1)
        {
            // a[x[i]] = y[i]
            int v = a[x[i]];
            ans -= vy[v] * r1.prefix_sum(v);
            ans -= r2.suffix_sum(v + 1);
            c1.incr(v, -1);
            c2.incr(v, -vy[v]);

            a[x[i]] = y[i];
            c1.incr(y[i], 1);
            c2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * r1.prefix_sum(y[i]);
            ans += r2.suffix_sum(y[i] + 1);
        }
        else
        {
            // b[x[i]] = y[i]
            int v = b[x[i]];
            ans -= vy[v] * c1.prefix_sum(v);
            ans -= c2.suffix_sum(v + 1);
            r1.incr(v, -1);
            r2.incr(v, -vy[v]);

            b[x[i]] = y[i];
            r1.incr(y[i], 1);
            r2.incr(y[i], vy[y[i]]);
            ans += vy[y[i]] * c1.prefix_sum(y[i]);
            ans += c2.suffix_sum(y[i] + 1);
        }
        cout << ans << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

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