func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   int P[N];   string T[N];   vector<int> G[N], depth[N + 1];   int DP[N][4];   int V[N];   int D[N];   int dfs(int c) {     D[c] = D[P[c]] + 1;     depth[D[c]].push_back(c);     if (T[c][0] ==  I ) return V[c];     if (T[c][0] ==  N ) return V[c] = !dfs(G[c][0]);     if (T[c][0] ==  A ) return V[c] = dfs(G[c][0]) & dfs(G[c][1]);     if (T[c][0] ==  O ) return V[c] = dfs(G[c][0]) | dfs(G[c][1]);     if (T[c][0] ==  X ) return V[c] = dfs(G[c][0]) ^ dfs(G[c][1]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, x, y;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> T[i];       if (T[i][0] ==  I )         cin >> V[i];       else if (T[i][0] ==  N ) {         cin >> x;         G[i].push_back(x);         P[x] = i;       } else {         cin >> x >> y;         G[i].push_back(x);         G[i].push_back(y);         P[x] = P[y] = i;       }     }     dfs(1);     DP[1][0] = 0;     DP[1][1] = 1;     for (int i = 0; i <= N; i++)       for (auto& c : depth[i]) {         if (c == 1) continue;         int p = P[c];         DP[c][V[c]] = DP[p][V[p]];         int o = !V[c];         if (T[p][0] ==  N ) DP[c][o] = DP[p][!o];         if (T[p][0] ==  A ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s == 2 ? 1 : 0)];         }         if (T[p][0] ==  O ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s > 0 ? 1 : 0)];         }         if (T[p][0] ==  X ) {           int s = V[G[p][0]] + V[G[p][1]] - V[c] + o;           DP[c][o] = DP[p][(s == 1 ? 1 : 0)];         }       }     for (int i = 1; i <= n; i++)       if (T[i][0] ==  I ) cout << DP[i][!V[i]];   }   