#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
ll INF = 1000000000000000;
struct segment_tree{
    int n; vector<ll> seg;
    segment_tree(vector<ll> v){
        n = v.size(); seg.resize(2*n);
        for(int i=0;i<n;i++) seg[i + n] = v[i];
        for(int i=n - 1;i>0;i--) seg[i] = seg[i<<1] + seg[i<<1|1];
    }
    void update(int p,ll val){
        for(seg[p += n] += val;p>1;p>>=1) seg[p>>1] = seg[p] + seg[p^1];
    }
    ll query(int l,int r){
        ll res = 0;
        for(l += n,r += n; l<r;l>>=1,r>>=1){
            if(l&1) res += seg[l++];
            if(r&1) res += seg[--r];
        }
        return res;
    }
    void clear(){for(int i=0;i<2*n;i++) seg[i] = 0;}
};

int t[200010],x[200010],y[200010];
int main(){
    int i,n,m,q; cin >> n >> m >> q;
    vector<int> a(n),b(m);
    map<int,int> mp;
    mp[0]++;
    for(i=0;i<q;i++){
        cin >> t[i] >> x[i] >> y[i];
        t[i]--; x[i]--; mp[y[i]]++;
    }
    vector<ll> v,u;
    for(auto x:mp) v.push_back(x.first);
    for(i=0;i<v.size();i++) mp[v[i]] = i;
    int k = v.size(); u.resize(k);
    vector<segment_tree> seg(2,segment_tree(u)),seg_num(2,segment_tree(u));
    for(i=0;i<n;i++) seg[0].update(mp[a[i]],a[i]),seg_num[0].update(mp[a[i]],1);
    for(i=0;i<m;i++) seg[1].update(mp[b[i]],b[i]),seg_num[1].update(mp[b[i]],1);
    ll ans = 0;
    for(i=0;i<q;i++){
        ll now;
        int j = x[i];
        if(t[i]==0) now = a[j];
        else now = b[j];
        ans -= seg_num[1 - t[i]].query(0,mp[now])*now + seg[1 - t[i]].query(mp[now],k);
        if(t[i]==0){
            seg[0].update(mp[a[j]],-a[j]); seg_num[0].update(mp[a[j]],-1); a[j] = y[i];
        }else{
            seg[1].update(mp[b[j]],-b[j]); seg_num[1].update(mp[b[j]],-1); b[j] = y[i];
        }
        seg[t[i]].update(mp[y[i]],y[i]); seg_num[t[i]].update(mp[y[i]],1);
        ans += seg_num[1 - t[i]].query(0,mp[y[i]])*y[i] + seg[1 - t[i]].query(mp[y[i]],k);
        cout << ans << "\n";
    }
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF32 = 1 << 29;
constexpr ll INF64 = 1LL << 62;
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-10;
const double PI = acos(-1);

#define ALL(v) (v).begin(),(v).end()
#define REP(i,n) for(int i=0,i_len=n; i<i_len; ++i)

template<typename T1,typename T2> bool chmax(T1 &a, T2 b) { if (a<b) { a=b; return 1; } return 0; }
template<typename T1,typename T2> bool chmin(T1 &a, T2 b) { if (b<a) { a=b; return 1; } return 0; }

void compress(vector<int> &x, map<int, int> &zip) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    for (int i = 0; i < x.size(); i++) {
        zip[x[i]] = i+1;
    }
}

template <typename T>
struct BIT {
    int N;
    std::vector<T> bit;

    BIT() = default;
    BIT(int n) {init(n);}
    void init(int n){
        N = n;
        bit.assign(n+1, 0);
    }
    T getSum(int i) {  // i番目までの要素の和を求める(1-index)
        T sum = 0;
        while (i > 0) {
            sum += bit[i];
            i -= i & -i;
        }
        return sum;
    }
    void add(int i, T x) {  // i番目の要素にxを加算
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};


int solve(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<P3> query;
    vector<int> num;
    REP(i,q){
        int t, x, y;
        cin >> t >> x >> y;
        x--;
        query.emplace_back(t,P(x,y));
        num.emplace_back(y);
    }
    num.emplace_back(0);
    map<int,int> zip;
    compress(num, zip);
    vector<ll> a(n), b(m);
    ll res = 0;
    BIT<ll> bitA(num.size()), bitB(num.size()), bitA2(num.size()), bitB2(num.size());
    bitA.add(zip[0], n);
    bitB.add(zip[0], m);
    REP(i,q){
        int t, x, y;
        t = query[i].first;
        x = query[i].second.first;
        y = query[i].second.second;
        if(t == 1){
            res -= bitB.getSum(zip[a[x]]) * a[x];
            res += bitB.getSum(zip[y]) * y;
            if(a[x] < y){
                res -= bitB2.getSum(zip[y]) - bitB2.getSum(zip[a[x]]);
            }else{
                res += bitB2.getSum(zip[a[x]]) - bitB2.getSum(zip[y]);
            }
            bitA.add(zip[a[x]],-1);
            bitA.add(zip[y],1);
            bitA2.add(zip[a[x]],-a[x]);
            bitA2.add(zip[y],y);
            a[x] = y;
        }else{
            res -= bitA.getSum(zip[b[x]]-1) * b[x];
            res += bitA.getSum(zip[y]-1) * y;
            if(b[x] < y){
                res -= bitA2.getSum(zip[y]-1) - bitA2.getSum(zip[b[x]]-1);
            }else{
                res += bitA2.getSum(zip[b[x]]-1) - bitA2.getSum(zip[y]-1);
            }
            bitB.add(zip[b[x]],-1);
            bitB.add(zip[y],1);
            bitB2.add(zip[b[x]], -b[x]);
            bitB2.add(zip[y], y);
            b[x] = y;
        }
        cout << res << endl;
    }
    return 0;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    // int t; cin >> t; for(int i=0;i<t;i++) solve();
    // while(!solve());
    solve();
    return 0;
}