#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 3;
int n;
int typ[N], val[N], chg[N], sum[N];
int kid[N][2];
char opt[5];
void dfs1(int p);
void dfs2(int p);
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", opt);
    if (opt[0] == 'A') typ[i] = 1;
    if (opt[0] == 'O') typ[i] = 2;
    if (opt[0] == 'X') typ[i] = 3;
    if (opt[0] == 'N') typ[i] = 4;
    if (opt[0] == 'I')
      scanf("%d", val + i);
    else {
      scanf("%d", kid[i]);
      if (opt[0] != 'N') scanf("%d", kid[i] + 1);
    }
  }
  dfs1(1);
  dfs2(1);
  for (int i = 2; i <= n; ++i)
    if (!typ[i]) printf("%d", sum[i] ^ val[1]);
  return 0;
}
void dfs1(int p) {
  if (kid[p][0]) dfs1(kid[p][0]);
  if (kid[p][1]) dfs1(kid[p][1]);
  if (typ[p] == 1) {
    val[p] = val[kid[p][0]] & val[kid[p][1]];
    if (val[kid[p][0]] + val[kid[p][1]] == 2)
      chg[kid[p][0]] = chg[kid[p][1]] = 1;
    if (val[kid[p][0]] + val[kid[p][1]] == 1)
      chg[kid[p][0]] = val[kid[p][0]] ^ 1, chg[kid[p][1]] = val[kid[p][1]] ^ 1;
  }
  if (typ[p] == 2) {
    val[p] = val[kid[p][0]] | val[kid[p][1]];
    if (val[kid[p][0]] + val[kid[p][1]] == 0)
      chg[kid[p][0]] = chg[kid[p][1]] = 1;
    if (val[kid[p][0]] + val[kid[p][1]] == 1)
      chg[kid[p][0]] = val[kid[p][0]], chg[kid[p][1]] = val[kid[p][1]];
  }
  if (typ[p] == 3)
    val[p] = val[kid[p][0]] ^ val[kid[p][1]],
    chg[kid[p][0]] = chg[kid[p][1]] = 1;
  if (typ[p] == 4) val[p] = !val[kid[p][0]], chg[kid[p][0]] = 1;
}
void dfs2(int p) {
  sum[p] = 1;
  if (kid[p][0] && chg[kid[p][0]]) dfs2(kid[p][0]);
  if (kid[p][1] && chg[kid[p][1]]) dfs2(kid[p][1]);
}
