#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n;
char s[N][10];
int l[N], r[N], is[N];
void dfs(int cur) {
  if (s[cur][1] == 'I') return;
  if (s[cur][1] == 'N') {
    dfs(l[cur]);
    is[cur] = 1 ^ is[l[cur]];
    return;
  }
  dfs(l[cur]);
  dfs(r[cur]);
  if (s[cur][1] == 'A') {
    is[cur] = is[l[cur]] & is[r[cur]];
    return;
  }
  if (s[cur][1] == 'O') {
    is[cur] = is[l[cur]] | is[r[cur]];
    return;
  }
  if (s[cur][1] == 'X') {
    is[cur] = is[l[cur]] ^ is[r[cur]];
    return;
  }
}
int cha[N];
void sol(int cur) {
  if (s[cur][1] == 'I') return;
  if (s[cur][1] == 'N') {
    cha[l[cur]] = cha[cur];
    sol(l[cur]);
    return;
  }
  if (s[cur][1] == 'A') {
    if (is[cur] != ((is[l[cur]] ^ 1) & is[r[cur]]))
      cha[l[cur]] = 1;
    else
      cha[l[cur]] = 0;
    if (is[cur] != ((is[l[cur]]) & (is[r[cur]] ^ 1)))
      cha[r[cur]] = 1;
    else
      cha[r[cur]] = 0;
    if (cha[cur] == 0) cha[l[cur]] = cha[r[cur]] = 0;
    sol(l[cur]);
    sol(r[cur]);
    return;
  }
  if (s[cur][1] == 'O') {
    if (is[cur] != ((is[l[cur]] ^ 1) | is[r[cur]]))
      cha[l[cur]] = 1;
    else
      cha[l[cur]] = 0;
    if (is[cur] != ((is[l[cur]]) | (is[r[cur]] ^ 1)))
      cha[r[cur]] = 1;
    else
      cha[r[cur]] = 0;
    if (cha[cur] == 0) cha[l[cur]] = cha[r[cur]] = 0;
    sol(l[cur]);
    sol(r[cur]);
    return;
  }
  if (s[cur][1] == 'X') {
    if (is[cur] != ((is[l[cur]] ^ 1) ^ is[r[cur]]))
      cha[l[cur]] = 1;
    else
      cha[l[cur]] = 0;
    if (is[cur] != ((is[l[cur]]) ^ (is[r[cur]] ^ 1)))
      cha[r[cur]] = 1;
    else
      cha[r[cur]] = 0;
    if (cha[cur] == 0) cha[l[cur]] = cha[r[cur]] = 0;
    sol(l[cur]);
    sol(r[cur]);
    return;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
    if (s[i][1] == 'I')
      scanf("%d", is + i);
    else if (s[i][1] == 'N')
      scanf("%d", l + i);
    else
      scanf("%d%d", l + i, r + i);
  }
  dfs(1);
  cha[1] = 1;
  sol(1);
  for (int i = 1; i <= n; ++i)
    if (s[i][1] == 'I') printf("%d", cha[i] ? (1 ^ is[1]) : is[1]);
  puts("");
  return 0;
}
