#include <bits/stdc++.h>

using namespace std;

typedef long long i64;

const int MAX_N = 200000 + 5;
const int A = 1e8;

int n[2], N, Q;
int a[2][MAX_N];
i64 ans;

int Root[2], total_node;
struct SegmentNode {
    i64 cnt, sum;
    int ls, rs;
} node[MAX_N * 50];

inline void segment_update(int i) {
    node[i].cnt = node[node[i].ls].cnt + node[node[i].rs].cnt;
    node[i].sum = node[node[i].ls].sum + node[node[i].rs].sum;
}
void segment_modify(int &i, int l, int r, int mp, int mv) {
    i = i ? i : ++ total_node;
    if (l == r) {
        node[i].cnt += mv;
        node[i].sum += 1ll * mv * l;
        return;
    }
    int mid = l + r >> 1;
    if (mp <= mid) {
        segment_modify(node[i].ls, l, mid, mp, mv);
    } else {
        segment_modify(node[i].rs, mid + 1, r, mp, mv);
    }
    segment_update(i);
}
i64 qcnt, qsum;
void segment_query(int i, int l, int r, int ql, int qr) {
    if (!i || ql <= l && r <= qr) {
        qcnt += node[i].cnt;
        qsum += node[i].sum;
        return;
    }
    int mid = l + r >> 1;
    if (ql <= mid) {
        segment_query(node[i].ls, l, mid, ql, qr);
    }
    if (mid + 1 <= qr) {
        segment_query(node[i].rs, mid + 1, r, ql, qr);
    }
}

int main() {
    scanf("%d%d%d", &n[0], &n[1], &Q);
    segment_modify(Root[0], 0, A, 0, n[0]);
    segment_modify(Root[1], 0, A, 0, n[1]);
    for (int i = 1; i <= Q; i ++) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y), t --;
        qcnt = qsum = 0;
        segment_query(Root[t ^ 1], 0, A, a[t][x], A);
        ans -= 1ll * (n[t ^ 1] - qcnt) * a[t][x] + qsum;
        segment_modify(Root[t], 0, A, a[t][x], -1);
        a[t][x] = y;
        segment_modify(Root[t], 0, A, a[t][x], 1);
        qcnt = qsum = 0;
        segment_query(Root[t ^ 1], 0, A, a[t][x], A);
        ans += 1ll * (n[t ^ 1] - qcnt) * a[t][x] + qsum;
        printf("%lld\n", ans);
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int MOD = 1000000007;

template <typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n) : n(n), dat(n + 1, 0) {}

    T sum(int idx) {  // 1-indexed
        T res(0);
        for (int i = idx; i > 0; i -= i & -i) res += dat[i];
        return res;
    }

    T sum(int l, int r) {  // 0-indexed
        return sum(r) - sum(l);
    }

    void add(int idx, T x) {  // 0-indexed
        idx++;
        for (int i = idx; i <= n; i += i & -i) dat[i] += x;
    }

    int lower_bound(T x) {
        if (x <= 0) return T(0);
        int res = 0, r = 1;
        while (r < n) r <<= 1;
        for (; r > 0; r >>= 1) {
            if (res + r <= n && dat[res + r] < x) {
                x -= dat[res + r];
                res += r;
            }
        }
        return res;
    }

    int upper_bound(T x) {
        return lower_bound(x + 1);
    }

    void print() {
        for (int i = 0; i < n; i++) cout << sum(i, i + 1) << " ";
        cout << endl;
    }
};

signed main() {
    int n, m, q;
    cin >> n >> m >> q;
    map<ll, int> mp;
    mp[0] = 0;
    int t[q], x[q];
    ll y[q];
    rep(i, q) {
        cin >> t[i] >> x[i] >> y[i];
        x[i]--;
        mp[y[i]] = 0;
    }
    int i = 0;
    for (auto& p : mp) {
        p.second = i++;
    }
    ll ans = 0;
    ll a[n] = {}, b[m] = {};
    BIT<int> A(mp.size()), B(mp.size());
    BIT<ll> Asum(mp.size()), Bsum(mp.size());
    A.add(0, n);
    B.add(0, m);
    rep(i, q) {
        if (t[i] == 1) {
            ans -= a[x[i]] * B.sum(0, mp[a[x[i]]]);
            ans -= Bsum.sum(mp[a[x[i]]], mp[y[i]]);
            ans += y[i] * B.sum(0, mp[y[i]]);
            A.add(mp[a[x[i]]], -1);
            A.add(mp[y[i]], 1);
            Asum.add(mp[a[x[i]]], -a[x[i]]);
            Asum.add(mp[y[i]], y[i]);
            a[x[i]] = y[i];
        } else {
            ans -= b[x[i]] * A.sum(0, mp[b[x[i]]]);
            ans -= Asum.sum(mp[b[x[i]]], mp[y[i]]);
            ans += y[i] * A.sum(0, mp[y[i]]);
            B.add(mp[b[x[i]]], -1);
            B.add(mp[y[i]], 1);
            Bsum.add(mp[b[x[i]]], -b[x[i]]);
            Bsum.add(mp[y[i]], y[i]);
            b[x[i]] = y[i];
        }
        cout << ans << endl;
    }
    return 0;
}