#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &a) {
  T x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  a = x * f;
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10) return (void)putchar(x + '0');
  write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
void writes(T x) {
  write(x);
  putchar(' ');
}
template <typename T, typename... Args>
void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
template <typename T, typename... Args>
void writes(T t, Args... args) {
  writes(t);
  writes(args...);
}
template <typename T, typename... Args>
void writeln(T t, Args... args) {
  writes(t);
  writes(args...);
  putchar('\n');
}
const int numcol = 2000000;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int n, m, q;
int lst[2000005], fa[2000005], res[2000005], cnt;
int col[305][305];
struct node {
  int x, y, id;
};
std::vector<node> add[2000005], del[2000005];
int id(int x, int y) { return (x - 1) * m + y; }
int find(int x) {
  int u = x;
  while (u != fa[u]) {
    u = fa[u] = fa[fa[u]];
  }
  return u;
}
void uni(int x, int y) {
  int xx = find(x), yy = find(y);
  if (xx == yy) return;
  fa[xx] = yy;
  cnt--;
}
void merge(int x, int y) {
  for (int i = 0; i < 4; i++) {
    int nowx = x + dx[i], nowy = y + dy[i];
    if (nowx < 1 || nowx > n || nowy < 1 || nowy > m ||
        col[nowx][nowy] != col[x][y])
      continue;
    uni(id(x, y), id(nowx, nowy));
  }
}
signed main() {
  read(n, m, q);
  for (int i = 1; i <= numcol; i++) lst[i] = q + 1;
  for (int i = 1; i <= q; i++) {
    int x, y, c;
    read(x, y, c);
    if (col[x][y] != c) lst[col[x][y]] = min(lst[col[x][y]], i);
    del[col[x][y]].push_back((node){x, y, i});
    col[x][y] = c;
    add[col[x][y]].push_back((node){x, y, i});
  }
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++) del[col[x][y]].push_back((node){x, y, q + 1});
  for (int c = 0; c <= numcol; c++) {
    if (add[c].empty()) continue;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) fa[id(i, j)] = id(i, j), col[i][j] = -1;
    cnt = 0;
    for (std::vector<node>::iterator it = add[c].begin(); it != add[c].end();
         it++) {
      if (col[it->x][it->y] == -1) cnt++;
      col[it->x][it->y] = c;
      merge(it->x, it->y);
      res[it->id] += cnt;
      if (it + 1 != add[c].end())
        res[(it + 1)->id] -= cnt;
      else
        res[lst[c]] -= cnt;
    }
  }
  for (int c = 0; c <= numcol; c++) {
    if (del[c].empty()) continue;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) fa[id(i, j)] = id(i, j), col[i][j] = -1;
    cnt = 0;
    for (std::vector<node>::reverse_iterator it = del[c].rbegin();
         it != del[c].rend(); it++) {
      if (col[it->x][it->y] == -1) cnt++;
      col[it->x][it->y] = c;
      merge(it->x, it->y);
      res[it->id] -= cnt;
      if (it + 1 != del[c].rend())
        res[(it + 1)->id] += cnt;
      else
        res[lst[c]] += cnt;
    }
  }
  int ans = 1;
  for (int i = 1; i <= q; i++) {
    ans += res[i];
    writeln(ans);
  }
  return 0;
}
