/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Max Matrix
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_E2 = 1 << 19; // = 524288
const int MAX_QN = 200000;

/* typedef */

typedef long long ll;

struct Qry {
  int t, x, y;
  Qry() {}
  Qry(int _t, int _x, int _y): t(_t), x(_x), y(_y) {}
  void read() { scanf("%d%d%d", &t, &x, &y); x--; }
  void print() { printf("Qry(%d,%d,%d)\n", t, x, y); }
};

template <typename T, const int MAX_E2>
struct SegTreeSum {
  int e2;
  T nodes[MAX_E2];
  SegTreeSum() {}

  void init(int n) {
    for (e2 = 1; e2 < n; e2 <<= 1);
    //fill(nodes, nodes + MAX_E2, 0);
  }

  T &geti(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
    }
  }
  void add(int i, T v) { set(i, geti(i) + v); }
  
  T sum_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return 0;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = sum_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = sum_range(r0, r1, k * 2 + 2, im, i1);
    return v0 + v1;
  }
  T sum_range(int r0, int r1) { return sum_range(r0, r1, 0, 0, e2); }
};

/* global variables */

Qry qs[MAX_QN];
int as[MAX_N], bs[MAX_N], uas[MAX_N + 1], ubs[MAX_N + 1];
SegTreeSum<int,MAX_E2> asti, bsti;
SegTreeSum<ll,MAX_E2> astl, bstl;

/* subroutines */

inline int get_index(int un, int us[], int v) {
  return lower_bound(us, us + un, v) - us;
}

/* main */

int main() {
  int n, m, qn;
  scanf("%d%d%d", &n, &m, &qn);

  int uan = 0, ubn = 0;
  uas[uan++] = ubs[ubn++] = 0;

  for (int i = 0; i < qn; i++) {
    qs[i].read();
    if (qs[i].t == 1) uas[uan++] = qs[i].y;
    else ubs[ubn++] = qs[i].y;
  }

  sort(uas, uas + uan);
  sort(ubs, ubs + ubn);
  uan = unique(uas, uas + uan) - uas;
  ubn = unique(ubs, ubs + ubn) - ubs;

  asti.init(uan), astl.init(uan);
  asti.set(0, n);
  bsti.init(ubn), bstl.init(ubn);
  bsti.set(0, m);

  ll sum = 0;
  for (int i = 0; i < qn; i++) {
    Qry &qi = qs[i];
    //qi.print();

    if (qi.t == 1) {
      int pa = as[qi.x];
      if (pa != qi.y) {
	int i0 = get_index(ubn, ubs, pa);
	sum -= (ll)pa * bsti.sum_range(0, i0) + bstl.sum_range(i0, ubn);
	int j0 = get_index(uan, uas, pa);
	asti.add(j0, -1), astl.add(j0, -pa);

	int i1 = get_index(ubn, ubs, qi.y);
	sum += (ll)qi.y * bsti.sum_range(0, i1) + bstl.sum_range(i1, ubn);
	int j1 = get_index(uan, uas, qi.y);
	asti.add(j1, 1), astl.add(j1, qi.y);
	as[qi.x] = qi.y;
      }
    }
    else {
      int pb = bs[qi.x];
      if (pb != qi.y) {
	int i0 = get_index(uan, uas, pb);
	sum -= (ll)pb * asti.sum_range(0, i0) + astl.sum_range(i0, uan);
	int j0 = get_index(ubn, ubs, pb);
	bsti.add(j0, -1), bstl.add(j0, -pb);

	int i1 = get_index(uan, uas, qi.y);
	sum += (ll)qi.y * asti.sum_range(0, i1) + astl.sum_range(i1, uan);
	int j1 = get_index(ubn, ubs, qi.y);
	bsti.add(j1, 1), bstl.add(j1, qi.y);
	bs[qi.x] = qi.y;
      }
    }

    printf("%lld\n", sum);
  }
  return 0;
}

#include "bits/stdc++.h"
#include <chrono>
#include <random>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2000000000
#define common cout << "Case #" << w+1 << ": "  
#define maxn 1000010

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

template< typename T> 
void PVecPrint(vector<T>&v) 
{ 
    for(int i=0;i<(int)v.size();i++) 
        cout << v[i].first << "," << v[i].second << ' '; 
    cout << '\n'; 
}
template<class T> 
void VecPrint(vector<T>&v)
{
    for(int i=0;i<v.size();i++) 
        cout << v[i] << ' ';
    cout << '\n';
}
/*---------------------------------------Code-----------------------------------------------------*/

struct FenwickTree {
    vector<lli> bit;  
    int n;

    void build(vector<lli> &a)
    {
        n=a.size();
        bit.resize(n);
        for (int i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    lli sum(int r) {
        lli ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    lli sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, lli delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int n,m,q;
vector<pair<int,pair<int,int> > >v;
set<int>s;
map<int,int>getInd;
lli ans=0;
FenwickTree F[4];
int tot;

lli getLessSum(int id,lli num)
{
    int numId=getInd[num];
    lli sum=F[id].sum(0,numId);
    return sum*1LL*num;
}

lli getMoreSum(int id,lli num)
{
    int numId=getInd[num];
    lli sum=F[id].sum(numId+1,tot+1);
    return sum;
}



int main()
{
    cin >> n >> m >> q;
    vector<int>v1(n+10,0),v2(m+10,0);
    v.resize(q);
    s.insert(0);
    for(int i=0;i<q;i++)
    {
        cin >> v[i].first >> v[i].second.first >> v[i].second.second;
        s.insert(v[i].second.second);
    }
    int ind=0;
    for(auto &num:s)
    {
        getInd[num]=ind;
        ++ind;
    }
    vector<lli>t(ind+10,0);
    for(int i=0;i<4;i++)
        F[i].build(t);
    tot=ind;
    F[0].add(0,n);
    F[1].add(0,m);
    for(int i=0;i<q;i++)
    {
        int t=v[i].first;
        if(t==1)
        {
            int pid=v[i].second.first,id=getInd[v1[pid]],nid=getInd[v[i].second.second];
            lli sum=getLessSum(1,v1[pid])+getMoreSum(3,v1[pid]);
            ans-=sum;
            F[0].add(id,-1);
            F[2].add(id,-v1[pid]);
            v1[pid]=v[i].second.second;
            F[0].add(nid,1);
            F[2].add(nid,v1[pid]);
            sum=getLessSum(1,v1[pid])+getMoreSum(3,v1[pid]);
            ans+=sum;
        }
        else
        {
            int pid=v[i].second.first,id=getInd[v2[pid]],nid=getInd[v[i].second.second];
            lli sum=getLessSum(0,v2[pid])+getMoreSum(2,v2[pid]);
            ans-=sum;
            F[1].add(id,-1);
            F[3].add(id,-v2[pid]);
            v2[pid]=v[i].second.second;
            F[1].add(nid,1);
            F[3].add(nid,v2[pid]);
            sum=getLessSum(0,v2[pid])+getMoreSum(2,v2[pid]);
            ans+=sum;
        }
        cout << ans << '\n';
    }
}