#include <iostream>
#include <vector>
#include <set>
#include <map>

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

int main(int argc, char **argv)
{
    int n, m, q;
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cin >> n >> m >> q;
    std::set<int> s = { 0 };
    std::vector<int> ta(q), xa(q), ya(q);

    for (int i = 0; i < q; i++) {
        std::cin >> ta[i] >> xa[i] >> ya[i];
        xa[i]--;
        s.insert(ya[i]);
    }
    std::vector<int> arr(s.begin(), s.end());
    std::map<int, int> map;
    int ll = s.size();

    for (int i = 0; i < ll; i++) map.emplace(arr[i], i);

    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); 
        std::cout << sum << std::endl;
    }
    return 0;
}
// give up
#include <bitset>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <list>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <valarray>

// alias, using declaration
using llint = long long; using ldouble = long double;
template <class T = llint> using vector = std::vector<T>;
template <class T = llint> using deque = std::deque<T>;
template <class T = llint> using list = std::list<T>;
template <class T = llint, class U = llint> using umap = std::unordered_map<T, U>;
template <class T = llint, class U = llint> using ummap = std::unordered_multimap<T, U>;
template <class T = llint> using uset = std::unordered_set<T>;
template <class T = llint> using umset = std::unordered_multiset<T>;
template <class T = llint, class U = T> using pair = std::pair<T, U>;
template <class T = llint> using varray = std::valarray<T>;
template <class T = llint, class U = vector<T>, class V = std::less<class U::value_type>> using pqueue = std::priority_queue<T, U, V>;
using std::array; using std::bitset; using std::string; using std::tuple;

// constant
constexpr llint INF = 0x7FFFFFFFFFFFFFFF;
constexpr llint INVALID = 0x8000000000000000;

namespace io {
  // in
  template <class... T, size_t... S> auto in(std::index_sequence<S...>) {tuple<T...> t; (..., (std::cin >> std::get<S>(t))); return t;}
  template <class... T, size_t... S> auto in(std::index_sequence<S...>, size_t n) {tuple<vector<T>...> t{vector<T>(n)...}; for (size_t i = 0; i < n; i++) (..., (std::cin >> std::get<S>(t)[i])); return t;}
  template <size_t N, class T = llint, class... U> auto in() {static_assert(N >= 1); if constexpr (N > 1) return in<N - 1, T, T, U...>(); else return in<T, U...>(std::index_sequence_for<T, U...>());}
  template <size_t N, class T = llint, class... U> auto in(size_t n) {static_assert(N >= 1); if constexpr (N > 1) return in<N - 1, T, T, U...>(n); else return in<T, U...>(std::index_sequence_for<T, U...>(), n);}
  template <size_t N, class T = llint> auto in(size_t n, size_t m) {static_assert(N == 1); vector<vector<T>> v(n, vector<T>(m)); for (auto&& vi : v) for (auto&& vij : vi) std::cin >> vij; return std::make_tuple(v);}
  // out
  template <class T, class... U> void out(const T& a, const U&... b) {std::cout << a << (sizeof...(b) ? " " : "\n"); if constexpr (sizeof...(b)) out(b...);}
  template <class T, class U = const char*> void out(const vector<T>& a, U d = " ") {for (auto&& b : a) std::cout << b << (&b != &a.back() ? d : "\n");}
}

int main() {
  // input
  auto [N, M, Q] = io::in<3>();
  auto [T, X, Y] = io::in<3>(Q);

  // solve
  vector<> a(N + 1), b(M + 1);
  umap<> Z;
  {
    Z.emplace(0, 0);
    vector<> Y_ = Y;
    std::sort(Y_.begin(), Y_.end());
    for (llint i = 0; i < Q; i++) Z.emplace(Y_.at(i), i + 1);
  }
  constexpr llint ST_SIZE = 1 << 19;
  vector<pair<>> st_a(ST_SIZE), st_b(ST_SIZE);
  auto update = [&Z](vector<pair<>>& st, llint v, llint n) {
    for (llint i = (ST_SIZE >> 1) + Z.at(v); i > 0; i >>= 1) {
      st.at(i).first += n;
      st.at(i).second += v * n;
    }
  };
  auto culc_line = [&Z](const vector<pair<>>& st, llint v) {
    llint r = st.at((ST_SIZE >> 1) + Z.at(v)).second;
    for (llint i = (ST_SIZE >> 1) + Z.at(v); i > 1; i >>= 1) {
      r += i & 1 ? st.at(i ^ 1).first * v : st.at(i ^ 1).second;
    }
    return r;
  };
  update(st_a, 0, N);
  update(st_b, 0, M);
  vector<> result(Q);
  for (llint i = 0; i < Q; i++) {
    auto& t = (T.at(i) == 1 ? a : b).at(X.at(i));
    auto& st_x = T.at(i) == 1 ? st_a : st_b;
    auto& st_y = T.at(i) == 1 ? st_b : st_a;
    update(st_x, t, -1);
    result.at(i) = -culc_line(st_y, t);
    t = Y.at(i);
    update(st_x, t, 1);
    result.at(i) += culc_line(st_y, t);
  }
  for (llint i = 1; i < Q; i++) result.at(i) += result.at(i - 1);

  // output
  io::out(result, "\n");
}