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

using ll = long long;

#define fi first
#define se second

const int N = 2e5 + 5;
const int INF = 2e9;
const ll LINF = 9e18;

struct query {
  int T, X, Y;
};

int n, m, q;
int a[N], b[N];
ll tree[4][N << 2];

// 0 = Sum_A, 1 = Sum_B, 2 = Freq_A, 3 = Freq_B

void update(int idx, int l, int r, int pos, ll val, int d) {
  if(l > pos || r < pos) return;
  if(l == r) {
    tree[d][idx] += val;
    return;
  }
  int mid = l + r >> 1;
  update(idx << 1, l, mid, pos, val, d);
  update(idx << 1 | 1, mid + 1, r, pos, val, d);
  tree[d][idx] = tree[d][idx << 1] + tree[d][idx << 1 | 1];
}

ll rangeSum(int idx, int l, int r, int from, int to, int d) {
  if(l > to || r < from) return 0;
  if(from <= l && r <= to) return tree[d][idx];
  int mid = l + r >> 1;
  return (
    rangeSum(idx << 1, l, mid, from, to, d) +
    rangeSum(idx << 1 | 1, mid + 1, r, from, to, d)
  );
}

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

  cin >> n >> m >> q;
  vector<query> Q;
  set<int> distinct;
  distinct.insert(0);
  while(q--) {
    int t, x, y; cin >> t >> x >> y;
    Q.push_back({t, x, y});
    distinct.insert(y);
  }
  int cnt = 0;
  map<int, int> idx;
  for(int u : distinct) {
    idx[u] = ++cnt;
  }
  int s = distinct.size();

  update(1, 1, s, idx[0], n, 2);
  update(1, 1, s, idx[0], m, 3);

  ll ans = 0;
  for(query u : Q) {
    if(u.T == 1) {
      int prv = idx[a[u.X]];
      int nxt = idx[u.Y];
    
      ans -= rangeSum(1, 1, s, 1, prv, 3) * a[u.X];
      ans += rangeSum(1, 1, s, 1, prv, 1);
      ans -= rangeSum(1, 1, s, 1, nxt, 1);
      ans += rangeSum(1, 1, s, 1, nxt, 3) * u.Y;

      update(1, 1, s, prv, -a[u.X], 0);
      update(1, 1, s, nxt, u.Y, 0);
      update(1, 1, s, prv, -1, 2);
      update(1, 1, s, nxt, 1, 2);

      a[u.X] = u.Y;
    } else {
      int prv = idx[b[u.X]];
      int nxt = idx[u.Y];

      ans -= rangeSum(1, 1, s, 1, prv, 2) * b[u.X];
      ans += rangeSum(1, 1, s, 1, prv, 0);
      ans -= rangeSum(1, 1, s, 1, nxt, 0);
      ans += rangeSum(1, 1, s, 1, nxt, 2) * u.Y;

      update(1, 1, s, prv, -b[u.X], 1);
      update(1, 1, s, nxt, u.Y, 1);
      update(1, 1, s, prv, -1, 3);
      update(1, 1, s, nxt, 1, 3);

      b[u.X] = u.Y;
    }
    cout << ans << "\n";
  }
}
#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;
}
