#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005;
int n,m,Q;
int a[N],b[N];
struct Segment_Tree
{
	struct Node
	{
		int ls,rs;
		int cnt;
		long long sum;
	}tree[N*20];
	int rt,tot;
	void modifycnt(int &i,int l,int r,int pos,int val)
	{
		if(!i) i=++tot;
		if(l==r)
		{
			tree[i].cnt+=val;
			return;
		}
		int mid=(l+r)/2;
		if(pos<=mid) modifycnt(tree[i].ls,l,mid,pos,val);
		else modifycnt(tree[i].rs,mid+1,r,pos,val);
		tree[i].cnt=tree[tree[i].ls].cnt+tree[tree[i].rs].cnt;
		return; 
	}
	void modifysum(int &i,int l,int r,int pos,int val)
	{
		if(!i) i=++tot;
		if(l==r)
		{
			tree[i].sum+=val;
			return;
		}
		int mid=(l+r)/2;
		if(pos<=mid) modifysum(tree[i].ls,l,mid,pos,val);
		else modifysum(tree[i].rs,mid+1,r,pos,val);
		tree[i].sum=tree[tree[i].ls].sum+tree[tree[i].rs].sum;
		return; 
	}
	int querycnt(int i,int l,int r,int L,int R)
	{
		if(!i) return 0;
		if(L<=l&&r<=R) return tree[i].cnt;
		int mid=(l+r)/2;
		int res=0;
		if(L<=r) res+=querycnt(tree[i].ls,l,mid,L,R);
		if(R>=l) res+=querycnt(tree[i].rs,mid+1,r,L,R);
		return res;
	}
	long long querysum(int i,int l,int r,int L,int R)
	{
		if(!i) return 0;
		if(L<=l&&r<=R) return tree[i].sum;
		int mid=(l+r)/2;
		long long res=0;
		if(L<=r) res+=querysum(tree[i].ls,l,mid,L,R);
		if(R>=l) res+=querysum(tree[i].rs,mid+1,r,L,R);
		return res;
	}
}TA,TB;
int main()
{
	scanf("%d%d%d",&n,&m,&Q);
	TA.modifycnt(TA.rt,1,1e8,0,n);
	TB.modifycnt(TB.rt,1,1e8,0,m);
	long long ans=0;
	while(Q--)
	{
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t==1)
		{
			TA.modifycnt(TA.rt,1,1e8,a[x],-1);
			TA.modifysum(TA.rt,1,1e8,a[x],-a[x]);
			TA.modifycnt(TA.rt,1,1e8,y,1);
			TA.modifysum(TA.rt,1,1e8,y,y);
			ans-=1LL*TB.querycnt(TB.rt,1,1e8,1,a[x])*a[x]+TB.querysum(TB.rt,1,1e8,a[x]+1,1e8);
			ans+=1LL*TB.querycnt(TB.rt,1,1e8,1,y)*y+TB.querysum(TB.rt,1,1e8,y+1,1e8);
			a[x]=y;
		}
		else if(t==2)
		{
			TB.modifycnt(TB.rt,1,1e8,b[x],-1);
			TB.modifysum(TB.rt,1,1e8,b[x],-b[x]);
			TB.modifycnt(TB.rt,1,1e8,y,1);
			TB.modifysum(TB.rt,1,1e8,y,y);
//			cerr<<"del"<<ans<<" "<<1LL*TA.querycnt(TA.rt,1,1e8,1,b[x])*b[x]-TA.querysum(TA.rt,1,1e8,b[x]+1,1e8)<<" "<<1LL*TA.querycnt(TA.rt,1,1e8,1,y)*y-TA.querysum(TA.rt,1,1e8,y+1,1e8)<<"\n";
			ans-=1LL*TA.querycnt(TA.rt,1,1e8,1,b[x])*b[x]+TA.querysum(TA.rt,1,1e8,b[x]+1,1e8);
			ans+=1LL*TA.querycnt(TA.rt,1,1e8,1,y)*y+TA.querysum(TA.rt,1,1e8,y+1,1e8);
			b[x]=y;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <tuple>

template <class E> struct FenwickTree {
    int _n;
    std::vector<E> data;

    FenwickTree(int n) : _n(n), data(n) { }

    void add(int p, E x) {
        ++p;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }
    E sum(int r) const {
        E s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
    E sum(int l, int r) const {
        return sum(r) - sum(l);
    }
};

long long proc(
    std::vector<int>             &cur,
    int                          x,
    int                          y,
    FenwickTree<int>             &ftcnt0,
    FenwickTree<long long>       &ftsum0,
    const FenwickTree<int>       &ftcnt1,
    const FenwickTree<long long> &ftsum1,
    const std::vector<int>       &arr)
{
    int v = cur[x];
    long long dem = (long long)ftcnt1.sum(0, v) * arr[v];
    long long cre = (long long)ftcnt1.sum(0, y) * arr[y];
    long long adj = (long long)ftsum1.sum(y, v);

    ftsum0.add(v, -arr[v]);
    ftcnt0.add(v, -1);
    cur[x] = y;
    ftsum0.add(y, arr[y]);
    ftcnt0.add(y, 1);

    return cre + adj - dem;
}

int main(int argc, char **argv)
{
    int n, m, q;
    std::cin >> n >> m >> q;
    std::vector<std::tuple<int, int, int>> txy;
    std::set<int> s = { 0 };

    for (int i = 0; i < q; i++) {
        int t, x, y;
        std::cin >> t >> x >> y;
        txy.push_back(std::make_tuple(t, x - 1, y));
        s.insert(y);
    }
    std::vector<int> arr(s.begin(), s.end());
    std::map<int, int> map;
    int ll = s.size();

    for (int i = 0; i < ll; i++) map.emplace(arr[i], i);

    FenwickTree<long long> ftsuma(ll);
    FenwickTree<long long> ftsumb(ll);
    FenwickTree<int>       ftcnta(ll);
    FenwickTree<int>       ftcntb(ll);
    std::vector<int> cura(n);
    std::vector<int> curb(m);
    ftcnta.add(0, n);
    ftcntb.add(0, m);
    long long sum = 0;

    for (const auto&e : txy) {
        int cy = map[std::get<2>(e)];
        sum += (std::get<0>(e) == 1) ? proc(cura, std::get<1>(e), cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                                     : proc(curb, std::get<1>(e), cy, ftcntb, ftsumb, ftcnta, ftsuma, arr); 
        std::cout << sum << std::endl;
    }
    return 0;
}