func_code_string: #include <bits/stdc++.h>   int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};   int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};   int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};   int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};   int dr2[] = {0, 0, 1, -1};   int dc2[] = {1, -1, 0, 0};   using namespace std;   vector<int> adj[1000005];   int a[1000005], b[1000005], dp1[1000005];   long long get(string t) {     if (t ==  IN ) return 0;     if (t ==  AND ) return 1;     if (t ==  XOR ) return 2;     if (t ==  OR ) return 3;     if (t ==  NOT ) return 4;   }   long long get1(long long x, long long y, long long v) {     if (a[v] == 1) return (x & y);     if (a[v] == 2) return (x ^ y);     if (a[v] == 3) return (x | y);   }   long long dfs(long long u) {     if (a[u] == 0) {       dp1[u] = b[u];       return dp1[u];     }     long long i, j;     if (adj[u].size() == 1) {       long long p = adj[u][0];       long long r = dfs(p) ^ 1;       dp1[u] = r;       return r;     } else {       long long p = adj[u][0];       long long q = adj[u][1];       p = dfs(p);       q = dfs(q);       long long r;       if (a[u] == 1)         r = p & q;       else if (a[u] == 2)         r = p ^ q;       else if (a[u] == 3)         r = p | q;       dp1[u] = r;       return r;     }   }   int dp[1000005][2][2];   long long cal(long long x, long long f, long long f1) {     if (f1 == 0) return (dp1[x] == f);     if (a[x] == 0) {       if (b[x] ^ 1 == f) return 1;       return 0;     }     int &r = dp[x][f][f1];     if (r != -1) return r;     r = 0;     if (adj[x].size() == 1) {       long long p = adj[x][0];       r = cal(p, f ^ 1, f1);       return r;     } else {       long long i, j;       long long p = adj[x][0];       long long q = adj[x][1];       for (i = 0; i < 2; i++) {         for (j = 0; j < 2; j++) {           long long p1 = get1(i, j, x);           if (p1 == f) {             long long r1 = cal(p, i, f1) & cal(q, j, 1 - f1);             long long r2 = cal(p, i, 1 - f1) & cal(q, j, f1);             r |= r1;             r |= r2;           }         }       }       return r;     }   }   int mark[1000005];   void print(long long x, long long f, long long f1) {     if (a[x] == 0) {       mark[x] = 1;       return;     }     if (adj[x].size() == 1) {       long long p = adj[x][0];       print(p, f ^ 1, f1);       return;     }     long long i, j;     long long p = adj[x][0];     long long q = adj[x][1];     for (i = 0; i < 2; i++) {       for (j = 0; j < 2; j++) {         long long p1 = get1(i, j, x);         if (p1 == f) {           long long r1 = cal(p, i, f1) & cal(q, j, 1 - f1);           if (r1 == 1) {             print(p, i, f1);           }           r1 = cal(p, i, 1 - f1) & cal(q, j, f1);           if (r1 == 1) {             print(q, j, f1);           }         }       }     }   }   int main() {     int n, i, j, x, y;     while (cin >> n) {       for (i = 1; i <= n; i++) {         string t;         cin >> t;         a[i] = get(t);         if (a[i] == 0 || a[i] == 4) {           cin >> x;           if (a[i] == 0)             b[i] = x;           else             adj[i].push_back(x);         } else {           cin >> x >> y;           adj[i].push_back(x);           adj[i].push_back(y);         }       }       long long ans = dfs(1);       memset(dp, -1, sizeof(dp));       long long p = cal(1, ans ^ 1, 1);       print(1, ans ^ 1, 1);       for (i = 1; i <= n; i++) {         if (a[i] == 0) {           if (mark[i] == 0)             cout << ans;           else             cout << (ans ^ 1);         }       }       cout << endl;     }     return 0;   }   