#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int a[100009];
struct nod {
  int f, lz;
  nod *l, *r;
  nod() {
    f = 0;
    lz = 0;
    l = NULL;
    r = NULL;
  }
  nod(int x, int z, nod *lf = NULL, nod *ri = NULL) {
    lz = z;
    f = x;
    l = lf;
    r = ri;
  }
};
nod *sg[100009];
void rfr(nod *root, int st, int en) {
  int d = en - st + 1;
  int p = root->lz;
  if (p == 0) return;
  root->f = d - root->f;
  root->lz = 0;
  if (st == en) return;
  if (root->l == NULL) root->l = new nod();
  if (root->r == NULL) root->r = new nod();
  nod *g1 = new nod(root->l->f, 1 - root->l->lz, root->l->l, root->l->r);
  nod *g2 = new nod(root->r->f, 1 - root->r->lz, root->r->l, root->r->r);
  root->l = g1;
  root->r = g2;
}
nod *chn(nod *root, int x, int z, int st = 0, int en = n * m - 1) {
  rfr(root, st, en);
  if (x < st || x > en) return root;
  if (st == en) return new nod(z, 0);
  int mid = st + (en - st) / 2;
  if (root->l == NULL) root->l = new nod();
  if (root->r == NULL) root->r = new nod();
  nod *rt1 = chn(root->l, x, z, st, mid);
  nod *rt2 = chn(root->r, x, z, mid + 1, en);
  return new nod(rt1->f + rt2->f, 0, rt1, rt2);
}
nod *go(nod *root, int qst, int qen, int st = 0, int en = n * m - 1) {
  rfr(root, st, en);
  if (qst > en || qen < st) return root;
  if (st >= qst && en <= qen) {
    nod *z = new nod(root->f, 1 - root->lz, root->l, root->r);
    rfr(z, st, en);
    return z;
  }
  int mid = st + (en - st) / 2;
  if (root->l == NULL) root->l = new nod();
  if (root->r == NULL) root->r = new nod();
  nod *rt1 = go(root->l, qst, qen, st, mid);
  nod *rt2 = go(root->r, qst, qen, mid + 1, en);
  return new nod(rt1->f + rt2->f, 0, rt1, rt2);
}
long long cal(nod *root, int qst = 0, int qen = n * m - 1, int st = 0,
              int en = n * m - 1) {
  rfr(root, st, en);
  if (st > qen || en < qst) return 0;
  if (st >= qst && en <= qen) return root->f;
  int mid = st + (en - st) / 2;
  if (root->l == NULL) root->l = new nod();
  if (root->r == NULL) root->r = new nod();
  return cal(root->l, qst, qen, st, mid) + cal(root->r, qst, qen, mid + 1, en);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> q;
  sg[0] = new nod();
  int t = 0, d, i, j;
  while (q--) {
    cin >> d;
    if (d == 1) {
      cin >> i >> j;
      int u = ((i - 1) * m + (j - 1));
      t++;
      sg[t] = chn(sg[t - 1], u, 1);
    }
    if (d == 2) {
      cin >> i >> j;
      int u = ((i - 1) * m + (j - 1));
      t++;
      sg[t] = chn(sg[t - 1], u, 0);
    }
    if (d == 3) {
      cin >> i;
      int u = (i - 1) * m, v = i * m - 1;
      t++;
      sg[t] = go(sg[t - 1], u, v);
    }
    if (d == 4) {
      cin >> i;
      t++;
      sg[t] = sg[i];
    }
    cout << cal(sg[t]) << endl;
  }
  return 0;
}
