#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int eval(int x, int y, char c) {
  if (c == 'A') {
    return x && y;
  } else if (c == 'O') {
    return x || y;
  } else if (c == 'X') {
    return x ^ y;
  } else {
    assert(!"Bad eval");
  }
}
int N;
char C[MAXN];
int A[MAXN], B[MAXN];
vector<int> adj[MAXN];
int ans[MAXN], flip[MAXN];
void dfs1(int x) {
  char cmd = C[x];
  if (cmd != 'I') {
    dfs1(A[x]);
  }
  if (cmd != 'I' && cmd != 'N') {
    dfs1(B[x]);
  }
  if (cmd == 'I') {
    ans[x] = A[x];
  } else if (cmd == 'N') {
    ans[x] = !ans[A[x]];
  } else {
    ans[x] = eval(ans[A[x]], ans[B[x]], cmd);
  }
}
void dfs2(int x) {
  flip[x] = true;
  char cmd = C[x];
  if (cmd == 'N') {
    dfs2(A[x]);
  } else if (cmd == 'A') {
    if (ans[A[x]] == 1) {
      dfs2(B[x]);
    }
    if (ans[B[x]] == 1) {
      dfs2(A[x]);
    }
  } else if (cmd == 'O') {
    if (ans[A[x]] == 0) {
      dfs2(B[x]);
    }
    if (ans[B[x]] == 0) {
      dfs2(A[x]);
    }
  } else if (cmd == 'X') {
    dfs2(A[x]);
    dfs2(B[x]);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    char buf[5];
    scanf("%s %d", buf, &A[i]);
    char &cmd = C[i];
    cmd = *buf;
    if (cmd == 'I') {
    } else if (cmd == 'N') {
      adj[i].push_back(A[i]);
    } else {
      scanf("%d", &B[i]);
      adj[i].push_back(A[i]);
      adj[i].push_back(B[i]);
    }
  }
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= N; i++) {
    if (C[i] == 'I') {
      printf("%d", (ans[1] ^ flip[i]));
    }
  }
  puts("");
}
