#include <bits/stdc++.h>
using namespace std;
int tu(int val) { return (1 << val); }
bool iset(int mask, int id) {
  if ((mask & tu(id)) != 0) return true;
  return false;
}
void doset(int &mask, int id) { mask |= tu(id); }
void dounset(int &mask, int id) { mask = mask & (~tu(id)); }
template <typename T>
string tos(T a) {
  stringstream ss;
  string ret;
  ss << a;
  ss >> ret;
  return ret;
}
bitset<1024> M[1024];
vector<int> adj[100007];
int r, c, ans[100007], sm, flip[1024], rcount[1024];
vector<pair<int, pair<int, int> > > data[100007];
void dfs(int u) {
  ans[u] = sm;
  int lm = adj[u].size();
  for (int(i) = (0); (i) < (lm); (i)++) {
    int v = adj[u][i];
    pair<int, pair<int, int> > dt = data[u][i];
    int t = dt.first;
    int x = dt.second.first;
    int y = dt.second.second;
    if (t == 1) {
      int exist = M[x][y] ^ flip[x];
      if (!exist) {
        M[x][y] = 1 - M[x][y];
        sm++;
        rcount[x]++;
        dfs(v);
        M[x][y] = 1 - M[x][y];
        sm--;
        rcount[x]--;
      } else
        dfs(v);
    } else if (t == 2) {
      int exist = M[x][y] ^ flip[x];
      if (exist) {
        M[x][y] = 1 - M[x][y];
        sm--;
        rcount[x]--;
        dfs(v);
        M[x][y] = 1 - M[x][y];
        sm++;
        rcount[x]++;
      } else
        dfs(v);
    } else if (t == 3) {
      int old = rcount[x];
      flip[x] = 1 - flip[x];
      rcount[x] = c - rcount[x];
      int dec = old - rcount[x];
      sm -= dec;
      dfs(v);
      sm += dec;
      flip[x] = 1 - flip[x];
      rcount[x] = old;
    } else {
      dfs(v);
    }
  }
}
int main() {
  int qu;
  cin >> r >> c >> qu;
  for (int(tm) = (1); (tm) < (qu + 1); (tm)++) {
    int t, x, y;
    t = x = y = -1;
    scanf("%d", &t);
    if (t == 4) {
      scanf("%d", &x);
      adj[x].push_back(tm);
      data[x].push_back(make_pair(t, make_pair(x, y)));
    } else if (t == 3) {
      scanf("%d", &x);
      x--;
      adj[tm - 1].push_back(tm);
      data[tm - 1].push_back(make_pair(t, make_pair(x, y)));
    } else {
      scanf("%d", &x);
      x--;
      scanf("%d", &y);
      y--;
      adj[tm - 1].push_back(tm);
      data[tm - 1].push_back(make_pair(t, make_pair(x, y)));
    }
  }
  dfs(0);
  for (int(i) = (1); (i) < (qu + 1); (i)++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
