#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 400005;
const int INF = 1e12;

int a[2*N], b[2*N], sa[4*N], sb[4*N];

void change_a(int p, int value, int val_sum = 0) {  
    for (a[p + N] += value, sa[p += N] += val_sum; p > 1; p >>= 1) a[p>>1] = a[p] + a[p^1], sa[p>>1] = sa[p] + sa[p^1];
}

void change_b(int p, int value, int val_sum = 0) {  
    for (b[p + N] += value, sb[p += N] += val_sum; p > 1; p >>= 1) b[p>>1] = b[p] + b[p^1], sb[p>>1] = sb[p] + sb[p^1];
}

int query_a(int l, int r) {  
  int res = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += a[l++];
    if (r&1) res += a[--r];
  }
  return res;
}

int query_b(int l, int r) {  
  int res = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += b[l++];
    if (r&1) res += b[--r];
  }
  return res;
}

int sum_a(int l, int r) {  
  int res = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += sa[l++];
    if (r&1) res += sa[--r];
  }
  return res;
}

int sum_b(int l, int r) {  
  int res = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += sb[l++];
    if (r&1) res += sb[--r];
  }
  return res;
}


signed main()
{
    FAST
    int tc=1;
    // cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,m,q;
        cin>>n>>m>>q;
        set<int> s;
        int arr[n] = {}, brr[m] = {};
        int t[q], x[q], y[q];
        s.insert(0);
        for(int i=0;i<q;i++)
        {
            cin>>t[i]>>x[i]>>y[i];
            x[i]--;
            s.insert(y[i]);
        }
        map<int, int> mp;
        int ind = 0;
        for(int i:s) mp[i] = ind++;
        change_a(0, n);
        change_b(0, m);
        int ans = 0;
        for(int i=0;i<q;i++)
        {
            if(t[i] == 1)
            {
                ans -= sum_b(mp[arr[x[i]]]+1, N);
                ans -= (query_b(0,mp[arr[x[i]]]+1)*arr[x[i]]);
                change_a(mp[arr[x[i]]], -1, -arr[x[i]]);
                change_a(mp[y[i]], 1, y[i]);
                ans += (query_b(0,mp[y[i]]+1)*y[i]);
                ans += sum_b(mp[y[i]]+1, N);
                arr[x[i]] = y[i];
            }
            else
            {
                ans -= sum_a(mp[brr[x[i]]]+1, N);
                ans -= (query_a(0,mp[brr[x[i]]]+1)*brr[x[i]]);
                change_b(mp[brr[x[i]]], -1, -brr[x[i]]);
                change_b(mp[y[i]], 1, y[i]);
                ans += (query_a(0,mp[y[i]]+1)*y[i]);
                ans += sum_a(mp[y[i]]+1, N);
                brr[x[i]] = y[i];
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using lli = long long;
using vi = vc<int>;
using ii = pair<int,int>;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }
lli poww(lli a, lli b){
	lli res = 1;
	while(b){ if(b&1) res = res*a; a=a*a; b>>=1;}
	return res;
}

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- しゃけ ツナマヨ ('-')7
typedef struct node *pn;
struct node{
	array<lli,2>a;
	pn l,r;
	node(){a[0]=a[1]=0; l = r = 0;}
};

lli g0(pn u){
	if(u)return u->a[0];
	return 0;
}

lli g1(pn u){
	if(u)return u->a[1];
	return 0;
}

array<lli,2> SUM(array<lli,2> a, array<lli,2> b){
	return {a[0]+b[0],a[1]+b[1]};
}

void upd(pn &u, int l, int r, int val, int side){
	if(l>r)return;
	if(l==r){
		u->a[0]+=side;
		u->a[1]=(u->a[0])*val;
		return;
	}
	int mid = (l+r)/2;
	if(val<=mid){
		if(!u->l)u->l = new node();
		upd(u->l,l,mid,val,side);
	}
	else{
		if(!u->r)u->r = new node();
		upd(u->r,mid+1,r,val,side);
	}
	u->a[0]=g0(u->l)+g0(u->r);
	u->a[1]=g1(u->l)+g1(u->r);
}


array<lli,2> find(pn &u, int l, int r, int ll, int rr){
	if(!u or l>r or l>rr or r<ll)return {0,0};
	if(ll<=l and r<=rr)return {g0(u),g1(u)};
	int mid = (l+r)/2;
	return SUM(find(u->l,l,mid,ll,rr), find(u->r,mid+1,r,ll,rr));
}

int main(){_

	auto solve=[&](){
		int L = 0, R = 1e8+5;
		int n,m,q; cin>>n>>m>>q;
		pn A = new node(), B = new node();
		upd(A,L,R,0,n);
		upd(B,L,R,0,m);
		vi aa(n,0), bb(m,0);
		lli sum = 0;
		auto g=[&](pn &a, pn &b, int &x, int y){
			auto tot = find(a,L,R,L,R);
			auto aux = find(a,L,R,L,x);
			sum-= (tot[1]-aux[1])+aux[0]*x;
			upd(b,L,R,x,-1);
			x = y;
			upd(b,L,R,x,+1);
			aux = find(a,L,R,L,x);
			sum+=(tot[1]-aux[1])+aux[0]*x;
		};
		fore(i,0,q){
			int t,x,y; cin>>t>>x>>y; x--;
			if(t==2)g(A,B,bb[x],y);
			else g(B,A,aa[x],y);
			cout<<sum<<ENDL;
		}

	};
	//int t; cin>>t; while(t--)
		solve();

}
