#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

struct BIT{
    int N;
    VI dat;
    BIT(int N):N(N){
        dat.resize(N+1,0);
    }
    ll sum(int k){
        k++;
        if(k==0)
            return 0;
        ll res=0;
        for(;k>0;k-=k&-k)
            res+=dat[k];
        return res;
    }
    ll sum(int l, int r){
        return sum(r)-sum(l-1);
    }
    void add(int k, ll x){
        k++;
        for(;k<=N;k+=k&-k)
            dat[k]+=x;
    }
    int lowerBound(int w){
        if (w<=0) return 0;
        int x=0;
        int k=1;
        while(k*2<=N) k*=2;
        for(;k>0;k/=2){
            if(x+k<=N&&dat[x+k]<w){
                w-=dat[x+k];
                x+=k;
            }
        }
        return x;
    }
};

int main(){
    ll n, m, q; cin >> n >> m >> q;
    VI t(q), x(q), y(q);
    REP(i,q){
        cin >> t[i] >> x[i] >> y[i];
    }
    VI sy=y; sy.push_back(0); sort(ALL(sy));
    map<int,int> mp; int cnt=1;
    REP(i,q+1){
        if(mp[sy[i]]==0){
            mp[sy[i]]=cnt;
            cnt++;
        }
    }
    ll ans=0;
    VI a(n,0), b(m,0);
    BIT bta(q+10), btb(q+10);
    BIT btax(q+10), btbx(q+10);
    btax.add(0,n);
    btbx.add(0,m);
    REP(i,q){
        if(t[i]==1){
            int j=x[i]-1;
            ll pre=btbx.sum(mp[a[j]]-1)*a[j]+btb.sum(mp[a[j]],q+3);
            ll ne =btbx.sum(mp[y[i]]-1)*y[i]+btb.sum(mp[y[i]],q+3);
            ans+=ne-pre;
            cout << ans << endl;
            bta.add(mp[a[j]],-a[j]);
            bta.add(mp[y[i]],y[i]);
            btax.add(mp[a[j]],-1);
            btax.add(mp[y[i]],1);
            a[j]=y[i];
        }
        else{
            int j=x[i]-1;
            ll pre=btax.sum(mp[b[j]]-1)*b[j]+bta.sum(mp[b[j]],q+3);
            ll ne =btax.sum(mp[y[i]]-1)*y[i]+bta.sum(mp[y[i]],q+3);
            ans+=ne-pre;
            cout << ans << endl;
            btb.add(mp[b[j]],-b[j]);
            btb.add(mp[y[i]],y[i]);
            btbx.add(mp[b[j]],-1);
            btbx.add(mp[y[i]],1);
            b[j]=y[i];
        }
    }
    return 0;
}
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x, y) make_pair(x, y)
#define mem(dp, a) memset(dp, a, sizeof dp);
#define all(a) a.begin(), a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll, ll> pp;

#define debug(x) cout << #x << " :: " << x << "\n";
#define debug2(x, y) cout << #x << " :: " << x << "\t" << #y << " :: " << y << "\n";
#define debug3(x, y, z) cout << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pp, null_type, less<pp>, rb_tree_tag, tree_order_statistics_node_update>

ll power(ll b, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2)
        {
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

map<ll, ll> ma1,ma2;    // ma2->reverse
ll n, m;

const ll maxN = 1000002;
ll bit[maxN][2][2];

void update(ll i, ll val,ll j,ll k)
{
    while (i < maxN )
    {
        bit[i][j][k] += val;
        i += (i & (-i));
    }
}

ll query(ll i,ll j,ll k)
{
    ll ans = 0;
    while (i > 0)
    {
        ans += bit[i][j][k];
        i -= (i & (-i));
    }
    return ans;
}

ll query_range(ll l, ll r,ll j,ll k)
{
    return query(r, j, k) - query(l - 1, j, k);
}

int main()
{
    boost
    ll q;
    cin >> n >> m >> q;
    pair<ll, pp> Q[q];
    ma1[0] = 0;
    for (ll i = 0; i < q; i++)
    {
        ll t, x, y;
        cin >> t >> x >> y;
        ma1[y] = 0;
        Q[i] = {t, {x, y}};
    }
    ll cnt = 1;
    vector<ll> a(n + 1), b(m + 1);
    for (auto &&temp : ma1) {
        temp.second = cnt++;
        ma2[cnt - 1] = temp.first;
    }
    ll ans = 0;
    update(ma1[0], n, 0, 0);    // [x][y] -> {a or b, freq or sum}
    update(ma1[0], m, 1, 0);
    for (ll i = 0; i < q; i++)  {
        ll t = Q[i].first, x = Q[i].second.first, y = Q[i].second.second;
        if (t==1)   {
            ll prev = (query(ma1[a[x]] - 1, 1, 0) * a[x]) + query_range(ma1[a[x]], maxN - 1, 1, 1);
            ans -= prev;
            update(ma1[a[x]], -1, 0, 0);
            update(ma1[a[x]], -a[x], 0, 1);
            a[x] = y;
            update(ma1[a[x]], 1, 0, 0);
            update(ma1[a[x]], a[x], 0, 1);
            ll cur = (query(ma1[a[x]] - 1, 1, 0) * a[x]) + query_range(ma1[a[x]], maxN - 1, 1, 1);
            ans += cur;
        }
        else    {
            ll prev = (query(ma1[b[x]] - 1, 0, 0) * b[x]) + query_range(ma1[b[x]], maxN - 1, 0, 1);
            ans -= prev;
            update(ma1[b[x]], -1, 1, 0);
            update(ma1[b[x]], -b[x], 1, 1);
            b[x] = y;
            update(ma1[b[x]], 1, 1, 0);
            update(ma1[b[x]], b[x], 1, 1);
            ll cur = (query(ma1[b[x]] - 1, 0, 0) * b[x]) + query_range(ma1[b[x]], maxN - 1, 0, 1);
            ans += cur;
        }
        cout << ans << "\n";
    }
    return 0;
}
