func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   bool vis[10005][10005], rev[10005];   struct E {     int nxt, to;   } e[MAXN];   int tot, head[MAXN];   inline void add(int x, int y) {     e[++tot] = (E){head[x], y};     head[x] = tot;   }   int opt[MAXN], X[MAXN], Y[MAXN], s[MAXN], m, n, q;   long long ans[MAXN];   void dfs(int x, int sum) {     int tmp = 0, i = x;     if (opt[i] == 1) {       if (vis[X[i]][Y[i]] == rev[X[i]])         tmp = 1, ++sum, ++s[X[i]], vis[X[i]][Y[i]] = !rev[X[i]];     }     if (opt[i] == 2) {       if (vis[X[i]][Y[i]] != rev[X[i]])         tmp = 1, --sum, --s[X[i]], vis[X[i]][Y[i]] = rev[X[i]];     }     if (opt[i] == 3) {       sum += m - s[X[i]] - s[X[i]];       rev[X[i]] ^= 1;       s[X[i]] = m - s[X[i]];     }     ans[i] = sum;     for (int i = head[x]; i; i = e[i].nxt) dfs(e[i].to, sum);     if (opt[x] == 1 && tmp) --sum, --s[X[i]], vis[X[i]][Y[i]] = rev[X[i]];     if (opt[x] == 2 && tmp) ++sum, ++s[X[i]], vis[X[i]][Y[i]] = !rev[X[i]];     if (opt[x] == 3)       sum -= m - s[X[i]] - s[X[i]], rev[X[i]] ^= 1, s[X[i]] = m - s[X[i]];   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= q; ++i) {       scanf( %d%d , &opt[i], &X[i]);       if (opt[i] < 3) scanf( %d , &Y[i]);       if (opt[i] == 4)         add(X[i], i);       else         add(i - 1, i);     }     dfs(0, 0);     for (int i = 1; i <= q; ++i) printf( %lld n , ans[i]);     return 0;   }   