func_code_string: #include <bits/stdc++.h>   using namespace std;   const int NN = 1010;   const int MM = 101010;   struct Node {     int id;     int x, y;   } Q[MM];   int a[NN][NN];   vector<int> adj[MM];   int ans[MM], f[MM];   int n, m, k;   void dfs(int u, int fa = 0, int crr = 0) {     if (Q[u].id == 1) {       int x = Q[u].x, y = Q[u].y;       if (!a[x][y]) {         a[x][y] = 1;         crr++;         f[u] = 1;       }     } else if (Q[u].id == 2) {       int x = Q[u].x, y = Q[u].y;       if (a[x][y]) {         a[x][y] = 0;         crr--;         f[u] = 1;       }     } else if (Q[u].id == 3) {       int x = Q[u].x;       for (int i = 1; i <= m; i++) {         if (a[x][i])           crr--;         else           crr++;         a[x][i] ^= 1;       }     }     ans[u] = crr;     for (int v : adj[u]) {       if (v == fa) continue;       dfs(v, u, ans[u]);     }     if (Q[u].id == 1) {       int x = Q[u].x, y = Q[u].y;       if (f[u]) a[x][y] = 0;     } else if (Q[u].id == 2) {       int x = Q[u].x, y = Q[u].y;       if (f[u]) a[x][y] = 1;     } else if (Q[u].id == 3) {       int x = Q[u].x;       for (int i = 1; i <= m; i++) a[x][i] ^= 1;     }   }   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= k; i++) {       int id, x, y;       scanf( %d , &id);       if (id < 3) {         scanf( %d %d , &x, &y);         Q[i] = {id, x, y};         adj[i - 1].push_back(i);         adj[i].push_back(i - 1);         continue;       }       scanf( %d , &x);       if (id == 4) {         adj[x].push_back(i);         adj[i].push_back(x);       } else {         adj[i - 1].push_back(i);         adj[i].push_back(i - 1);       }       Q[i] = {id, x, 0};     }     dfs(0);     for (int i = 1; i <= k; i++) {       printf( %d n , ans[i]);     }     return 0;   }   