#include <bits/stdc++.h>
using namespace std;
int S[1000007], X[1000007], Y[1000007], W[1000007], C[1000007];
char s[10];
void dfs(int x) {
  if (!S[x]) {
    W[x] = X[x];
    return;
  }
  dfs(X[x]);
  if (S[x] > 1) dfs(Y[x]);
  if (S[x] == 1) W[x] = W[X[x]] ^ 1;
  if (S[x] == 2) W[x] = W[X[x]] & W[Y[x]];
  if (S[x] == 3) W[x] = W[X[x]] | W[Y[x]];
  if (S[x] == 4) W[x] = W[X[x]] ^ W[Y[x]];
}
void change(int x) {
  if (!S[x]) return;
  if (S[x] == 1) C[X[x]] = C[x];
  if (S[x] == 2) {
    if (!W[X[x]] && !W[Y[x]])
      C[X[x]] = C[Y[x]] = 0;
    else if (W[X[x]] && W[Y[x]])
      C[X[x]] = C[Y[x]] = C[x];
    else
      C[X[x]] = W[X[x]] ? 0 : C[x], C[Y[x]] = W[Y[x]] ? 0 : C[x];
  }
  if (S[x] == 3) {
    if (!W[X[x]] && !W[Y[x]])
      C[X[x]] = C[Y[x]] = C[x];
    else if (W[X[x]] && W[Y[x]])
      C[X[x]] = C[Y[x]] = 0;
    else
      C[X[x]] = W[X[x]] ? C[x] : 0, C[Y[x]] = W[Y[x]] ? C[x] : 0;
  }
  if (S[x] == 4) C[X[x]] = C[Y[x]] = C[x];
  change(X[x]);
  if (S[x] > 1) change(Y[x]);
}
int main() {
  int n, m, x, u, v, w, q;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf(" %s%d", s, &X[i]);
    if (s[0] == 'I') S[i] = 0;
    if (s[0] == 'N') S[i] = 1;
    if (s[0] == 'A') S[i] = 2;
    if (s[0] == 'O') S[i] = 3;
    if (s[0] == 'X') S[i] = 4;
    if (S[i] > 1) scanf("%d", &Y[i]);
  }
  C[1] = 1;
  dfs(1);
  change(1);
  for (int i = 1; i <= n; i++) {
    if (!S[i]) printf("%d", W[1] ^ C[i]);
  }
  printf("\n");
  return 0;
}
