#include <bits/stdc++.h>
using namespace std;
char s[1000005][5];
int f[1000005];
int road[1000005][2];
int sign[1000005];
int n;
string ans;
int dfs1(int x) {
  if (strcmp(s[x], "AND") == 0) {
    int ans1 = dfs1(road[x][0]);
    int ans2 = dfs1(road[x][1]);
    return f[x] = ans1 && ans2;
  }
  if (strcmp(s[x], "XOR") == 0) {
    int ans1 = dfs1(road[x][0]);
    int ans2 = dfs1(road[x][1]);
    return f[x] = ans1 != ans2;
  }
  if (strcmp(s[x], "OR") == 0) {
    int ans1 = dfs1(road[x][0]);
    int ans2 = dfs1(road[x][1]);
    return f[x] = ans1 || ans2;
  }
  if (strcmp(s[x], "NOT") == 0) return f[x] = 1 - dfs1(road[x][0]);
  if (strcmp(s[x], "IN") == 0) return f[x] = road[x][0];
}
void dfs2(int x, int value) {
  if (value == 0) {
    if (strcmp(s[x], "AND") == 0) {
      dfs2(road[x][0], 0);
      dfs2(road[x][1], 0);
    }
    if (strcmp(s[x], "XOR") == 0) {
      dfs2(road[x][0], 0);
      dfs2(road[x][1], 0);
    }
    if (strcmp(s[x], "OR") == 0) {
      dfs2(road[x][0], 0);
      dfs2(road[x][1], 0);
    }
    if (strcmp(s[x], "NOT") == 0) {
      dfs2(road[x][0], 0);
    }
    if (strcmp(s[x], "IN") == 0) {
      sign[x] = 0;
    }
  } else {
    if (strcmp(s[x], "IN") == 0) {
      sign[x] = 1;
    }
    if (strcmp(s[x], "NOT") == 0) {
      dfs2(road[x][0], 1);
    }
    if (strcmp(s[x], "XOR") == 0) {
      dfs2(road[x][0], 1);
      dfs2(road[x][1], 1);
    }
    if (strcmp(s[x], "AND") == 0) {
      if (f[road[x][0]] == 1 && f[road[x][1]] == 1) {
        dfs2(road[x][0], 1);
        dfs2(road[x][1], 1);
      }
      if (f[road[x][0]] == 1 && f[road[x][1]] == 0) {
        dfs2(road[x][0], 0);
        dfs2(road[x][1], 1);
      }
      if (f[road[x][0]] == 0 && f[road[x][1]] == 1) {
        dfs2(road[x][0], 1);
        dfs2(road[x][1], 0);
      }
      if (f[road[x][0]] == 0 && f[road[x][1]] == 0) {
        dfs2(road[x][0], 0);
        dfs2(road[x][1], 0);
      }
    }
    if (strcmp(s[x], "OR") == 0) {
      if (f[road[x][0]] == 1 && f[road[x][1]] == 1) {
        dfs2(road[x][0], 0);
        dfs2(road[x][1], 0);
      }
      if (f[road[x][0]] == 1 && f[road[x][1]] == 0) {
        dfs2(road[x][0], 1);
        dfs2(road[x][1], 0);
      }
      if (f[road[x][0]] == 0 && f[road[x][1]] == 1) {
        dfs2(road[x][0], 0);
        dfs2(road[x][1], 1);
      }
      if (f[road[x][0]] == 0 && f[road[x][1]] == 0) {
        dfs2(road[x][0], 1);
        dfs2(road[x][1], 1);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (strcmp(s[i], "AND") == 0) cin >> road[i][0] >> road[i][1];
    if (strcmp(s[i], "IN") == 0) cin >> road[i][0];
    if (strcmp(s[i], "XOR") == 0) cin >> road[i][0] >> road[i][1];
    if (strcmp(s[i], "OR") == 0) cin >> road[i][0] >> road[i][1];
    if (strcmp(s[i], "NOT") == 0) cin >> road[i][0];
  }
  dfs1(1);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++) {
    if (strcmp(s[i], "IN") == 0) {
      char temp = f[1];
      if (sign[i] == 1) temp = 1 - temp;
      temp += '0';
      ans += temp;
    }
  }
  cout << ans << endl;
  return 0;
}
