#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

template<class T> struct Fenwick {
    int n;
    T* d;
    Fenwick() : n(0), d(NULL) {}
    Fenwick(int n_) : n(n_) {
	d = new T[n_]();
    }
    Fenwick(const Fenwick &y) : n(y.n) {
	d = new T[n];
	memcpy(d, y.d, sizeof (T) * n);
    }
    ~Fenwick() {
	delete[] d; d = NULL;
	n = 0;
    }
    friend void swap(Fenwick &x, Fenwick &y) {
	swap(x.n, y.n); swap(x.d, y.d);
    }
    Fenwick& operator=(Fenwick y) {
	swap(*this, y);
	return *this;
    }
    inline void add(int i, const T &x) {
	for (; i<n; i|=i+1) d[i] += x;
    }
    inline T sum(int r) const {
	T s = T();
	for (; r; r&=r-1) s += d[r-1];
	return s;
    }
    T sum(int l, int r) const {
	return sum(r) - sum(l);
    }
};
template<class T> void sort_unique(vector<T> &v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}
int N, M, Q;
VI A, B;

int T[200011];
int X[200011];
int Y[200011];

vector<pair<int, int> > Ys;
int get_idx(int val, int type) {
    auto it = lower_bound(Ys.begin(), Ys.end(), make_pair(val, type));
    assert(it != Ys.end());
    assert(it->first == val);
    assert(it->second == type);
    return it - Ys.begin();
}

void MAIN() {
    scanf("%d%d%d", &N, &M, &Q);
    A.resize(N, 0);
    B.resize(M, 0);
    REP (i, Q) {
	scanf("%d%d%d", T+i, X+i, Y+i);
	X[i]--;
    }

    Ys.emplace_back(0, 1);
    Ys.emplace_back(0, 2);

    REP (i, Q) {
	Ys.emplace_back(Y[i], T[i]);
    }

    sort_unique(Ys);

    Fenwick<int> FAC(Ys.size());
    Fenwick<int> FBC(Ys.size());
    Fenwick<LL> FAS(Ys.size());
    Fenwick<LL> FBS(Ys.size());

    assert(get_idx(0, 1) == 0);
    assert(get_idx(0, 2) == 1);

    FAC.add(get_idx(0, 1), N);
    FBC.add(get_idx(0, 2), M);

    LL ans = 0;

    REP (i, Q) {
	const int t = T[i];
	const int x = X[i];
	const int y = Y[i];

	if (t == 1) {
	    int from = get_idx(A[x], 1);
	    ans -= (LL) FBC.sum(from) * A[x];
	    ans -= FBS.sum(from, Ys.size());

	    FAC.add(from, -1);
	    FAS.add(from, -A[x]);

	    int to = get_idx(y, 1);
	    ans += (LL) FBC.sum(to) * y;
	    ans += FBS.sum(to, Ys.size());

	    FAC.add(to, 1);
	    FAS.add(to, y);

	    A[x] = y;
	} else {
	    int from = get_idx(B[x], 2);
	    ans -= (LL) FAC.sum(from) * B[x];
	    ans -= FAS.sum(from, Ys.size());

	    FBC.add(from, -1);
	    FBS.add(from, -B[x]);

	    int to = get_idx(y, 2);
	    ans += (LL) FAC.sum(to) * y;
	    ans += FAS.sum(to, Ys.size());

	    FBC.add(to, 1);
	    FBS.add(to, y);

	    B[x] = y;
	}

	printf("%lld\n", ans);
    }

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using VS = vector<string>;
using VC = vector<char>;
using Q = queue<int>;
using P = pair<int, int>;
using llP = pair<ll, ll>;

#define pb push_back

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

void _print(ostream&){}
template<class T,class...U>
void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>
void out(const T&...t){_print(cout,t...);}
template<class...T>
void err(const T&...t){_print(cerr,t...);}
#define strictout(x, precision) cout<<fixed<<setprecision(precision)<<(x)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define max5 100010
#define max9 1000000010

#define YesNo(x) cout<<(x?"Yes":"No")<<endl
#define YESNO(x) cout<<(x?"YES":"NO")<<endl
#define yesno(x) cout<<(x?"yes":"no")<<endl
#define yay(x) cout<<(x?"yay":":(")<<endl

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
  inn(n, w);
  out(n / w);
  return 0;
}
