#include <bits/stdc++.h>
const int MAXN = 1e6 + 20;
int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (48 ^ c), c = getchar();
  return x;
}
int typ[MAXN];
int ch[2][MAXN];
bool val[MAXN];
void dfs1(const int &u) {
  if (typ[u] == 0) return;
  dfs1(ch[0][u]);
  if (typ[u] != 1) dfs1(ch[1][u]);
  if (typ[u] == 1)
    val[u] = !val[ch[0][u]];
  else if (typ[u] == 2)
    val[u] = val[ch[0][u]] & val[ch[1][u]];
  else if (typ[u] == 3)
    val[u] = val[ch[0][u]] | val[ch[1][u]];
  else
    val[u] = val[ch[0][u]] ^ val[ch[1][u]];
}
int affect[MAXN];
void dfs2(const int &u) {
  if (typ[u] == 0) return;
  if (typ[u] == 1) {
    affect[ch[0][u]] = affect[u];
  } else if (typ[u] == 2) {
    if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 2) {
      affect[ch[0][u]] = affect[u];
      affect[ch[1][u]] = affect[u];
    } else if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 1) {
      affect[(val[ch[0][u]] == 0) ? ch[0][u] : ch[1][u]] = affect[u];
      affect[(val[ch[0][u]] == 1) ? ch[0][u] : ch[1][u]] =
          (val[ch[0][u]] == 1) ? ch[0][u] : ch[1][u];
    } else {
      affect[ch[0][u]] = ch[0][u];
      affect[ch[1][u]] = ch[1][u];
    }
  } else if (typ[u] == 3) {
    if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 0) {
      affect[ch[0][u]] = affect[u];
      affect[ch[1][u]] = affect[u];
    } else if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 1) {
      affect[(val[ch[0][u]] == 0) ? ch[0][u] : ch[1][u]] =
          (val[ch[0][u]] == 0) ? ch[0][u] : ch[1][u];
      affect[(val[ch[0][u]] == 1) ? ch[0][u] : ch[1][u]] = affect[u];
    } else {
      affect[ch[0][u]] = ch[0][u];
      affect[ch[1][u]] = ch[1][u];
    }
  } else {
    if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 0) {
      affect[ch[0][u]] = affect[u];
      affect[ch[1][u]] = affect[u];
    } else if ((int)val[ch[0][u]] + (int)val[ch[1][u]] == 1) {
      affect[ch[0][u]] = affect[u];
      affect[ch[1][u]] = affect[u];
    } else {
      affect[ch[0][u]] = affect[u];
      affect[ch[1][u]] = affect[u];
    }
  }
  dfs2(ch[0][u]);
  if (typ[u] != 1) dfs2(ch[1][u]);
}
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) {
    char Typ[10];
    scanf("%s", Typ);
    if (Typ[0] == 'I') {
      typ[i] = 0;
      val[i] = read();
    } else if (Typ[0] == 'N') {
      typ[i] = 1;
      ch[0][i] = read();
    } else if (Typ[0] == 'A') {
      typ[i] = 2;
      ch[0][i] = read();
      ch[1][i] = read();
    } else if (Typ[0] == 'O') {
      typ[i] = 3;
      ch[0][i] = read();
      ch[1][i] = read();
    } else {
      typ[i] = 4;
      ch[0][i] = read();
      ch[1][i] = read();
    }
  }
  dfs1(1);
  affect[1] = 1, dfs2(1);
  for (int i = 1; i <= n; ++i)
    if (typ[i] == 0) putchar('0' + (val[1] ^ (bool)(affect[i] == 1)));
}
