#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


struct TrieNode{
	int n = 0;
	long long sum = 0;
	TrieNode* l = nullptr, * r = nullptr;
};

class Trie {
public:
	Trie() { root = new TrieNode(); }

	void insert(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n++;
			t->sum += x;
			if (x >> i &1) {
				if (t->r == nullptr) t->r = new TrieNode;
				t = t->r;
			}
			else {
				if (t->l == nullptr) t->l = new TrieNode;
				t = t->l;
			}
		}
		t->n++;
		t->sum += x;
	}

	void erase(int x) {
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			t->n--;
			t->sum -= x;
			if (x >> i & 1) {
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		t->n--;
		t->sum -= x;
	}

	pair<int, long long> query(int x) const{
		pair<int, long long > ret(0, 0);
		TrieNode* t = root;
		for (int i = 30; i >= 0; i--) {
			if (t == nullptr)break;
			if (x >> i & 1) {
				if (t->l) {
					ret.first += t->l->n;
					ret.second += t->l->sum;
				}
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return ret;
	}
private:
	TrieNode* root;
};



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, m, q;
	cin >> n >> m >> q;

	vector<int> a(n, 0), b(m, 0);

	Trie ta, tb;
	rep(i, n) ta.insert(0);
	rep(i, m)tb.insert(0);

	long long ans = 0;
	rep(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		x--;

		if (t == 1) {
			auto p = tb.query(a[x]);
			ans -= (long long)p.first * a[x];
			ans += p.second;
		
			p = tb.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			ta.erase(a[x]);
			ta.insert(y);
			a[x] = y;
		}
		else {
			auto p = ta.query(b[x]);
			ans -= (long long)p.first * b[x];
			ans += p.second;
			
			p = ta.query(y);
			ans += (long long)p.first * y;
			ans -= p.second;

			tb.erase(b[x]);
			tb.insert(y);
			b[x] = y;
		}
		cout << ans << endl;
	}


	return 0;
}

#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstdlib>

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;
}

static char buf[2000000];
int ptr = 0;
int len = 0;

void init()
{
    len = fread(buf, 1, sizeof buf, stdin);
    ptr = 0;
}

int myread()
{
    int acc = 0;
    if (len <= ptr) init();
    while (buf[ptr] < '0' | buf[ptr] > '9') {
        ptr++;
        if (len <= ptr) init();
    }
    while (buf[ptr] >= '0' && buf[ptr] <= '9') {
        acc = acc * 10 + buf[ptr] - '0';
        ptr++;
        if (len <= ptr) init();
    }
    return acc;
}

int main(int argc, char **argv)
{
    int n = myread(), m = myread(), q = myread();

    std::vector<int> ta(q), xa(q), ya(q), arr(q + 1);

    for (int i = 0; i < q; i++) {
        ta[i] = myread();
        xa[i] = myread();
        ya[i] = myread();

        arr[i + 1] = ya[i];
        xa[i]--;
    }
    std::sort(arr.begin(), arr.end());
    std::map<int, int> map;
    int ll = 0;
    map.emplace(0, 0);
    for (int ii = 1; ii <= q; ii++) {
        if (arr[ii] != arr[ll]) {
            ++ll;
            arr[ll] = arr[ii];
            map.emplace(arr[ii], ll);
        }
    }
    ++ll;

    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 (int i = 0; i < q; i++) {
        int cy = map[ya[i]];
        sum += (ta[i] == 1) ? proc(cura, xa[i], cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                            : proc(curb, xa[i], cy, ftcntb, ftsumb, ftcnta, ftsuma, arr); 
        printf("%lld\n", sum);
    }
    return 0;
}