#include <bits/stdc++.h>
using namespace std;
const int M = 2010;
const int N = 1000010;
int n;
int ls[N], rs[N], v[N];
int f[N];
void dfs1(int x) {
  if (v[x] == 4) {
    f[x] = ls[x];
    return;
  } else if (v[x] == 3) {
    dfs1(ls[x]);
    if (f[ls[x]] == 1)
      f[x] = 0;
    else
      f[x] = 1;
  } else {
    dfs1(ls[x]);
    dfs1(rs[x]);
    if (v[x] == 0)
      f[x] = (f[ls[x]] & f[rs[x]]);
    else if (v[x] == 1)
      f[x] = (f[ls[x]] | f[rs[x]]);
    else if (v[x] == 2)
      f[x] = (f[ls[x]] ^ f[rs[x]]);
  }
}
int d[N];
void dfs2(int x) {
  if (v[x] == 4) return;
  if (v[x] == 3) {
    d[ls[x]] = 1;
    dfs2(ls[x]);
  } else if (v[x] == 2) {
    d[ls[x]] = 1;
    d[rs[x]] = 1;
    dfs2(rs[x]);
    dfs2(ls[x]);
  } else if (v[x] == 1) {
    if (f[ls[x]] && f[rs[x]]) return;
    if (!f[ls[x]] && !f[rs[x]]) {
      d[ls[x]] = d[rs[x]] = 1;
      dfs2(ls[x]);
      dfs2(rs[x]);
    } else {
      if (f[ls[x]]) {
        d[ls[x]] = 1;
        dfs2(ls[x]);
      } else {
        d[rs[x]] = 1;
        dfs2(rs[x]);
      }
    }
  } else {
    if (!f[ls[x]] && !f[rs[x]]) return;
    if (f[ls[x]] && f[rs[x]]) {
      d[ls[x]] = d[rs[x]] = 1;
      dfs2(ls[x]);
      dfs2(rs[x]);
    } else {
      if (!f[ls[x]]) {
        d[ls[x]] = 1;
        dfs2(ls[x]);
      } else {
        d[rs[x]] = 1;
        dfs2(rs[x]);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char ch[10];
    scanf("%s", ch);
    if (ch[0] == 'I' || ch[0] == 'N') {
      scanf("%d", &ls[i]);
      if (ch[0] == 'I')
        v[i] = 4;
      else
        v[i] = 3;
    } else {
      if (ch[0] == 'A')
        v[i] = 0;
      else if (ch[0] == 'O')
        v[i] = 1;
      else
        v[i] = 2;
      scanf("%d%d", &ls[i], &rs[i]);
    }
  }
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; i++) {
    if (v[i] == 4) {
      if (d[i]) {
        if (f[1])
          printf("0");
        else
          printf("1");
      } else
        printf("%d", f[1] == 1);
    }
  }
  return 0;
}
