#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int n, fa[maxn], son[2][maxn], col[maxn], v[maxn], a[maxn], cnt;
int st[maxn << 1], to[maxn << 1], nt[maxn << 1], topt;
int dfn[maxn], line[maxn], sum[maxn], ss[maxn], dfn_num, si[maxn];
bool ok[maxn];
char s[100];
void add(int x, int y) {
  to[++topt] = y;
  nt[topt] = st[x];
  st[x] = topt;
}
void dfs(int x) {
  int p = st[x];
  dfn[x] = ++dfn_num;
  line[topt] = x;
  si[x] = 1;
  while (p) {
    dfs(to[p]);
    si[x] += si[to[p]];
    p = nt[p];
  }
  if (col[x] == 1) v[x] = v[son[0][x]] && v[son[1][x]];
  if (col[x] == 2) v[x] = v[son[0][x]] || v[son[1][x]];
  if (col[x] == 3) v[x] = v[son[0][x]] ^ v[son[1][x]];
  if (col[x] == 4) v[x] = !v[son[0][x]];
}
void fz(int x) {
  ok[x] = 0;
  int p = st[x];
  while (p) {
    fz(to[p]);
    p = nt[p];
  }
}
void work(int x) {
  if (si[x] == 1 || !x) return;
  if (col[x] == 1) {
    bool fa = 0, fb = 0;
    if (v[son[0][x]] == 0) fz(son[1][x]), fb = 1;
    if (v[son[1][x]] == 0) fz(son[0][x]), fa = 1;
    if (!fa) work(son[0][x]);
    if (!fb) work(son[1][x]);
  } else if (col[x] == 2) {
    bool fa = 0, fb = 0;
    if (v[son[0][x]] == 1) fz(son[1][x]), fb = 1;
    if (v[son[1][x]] == 1) fz(son[0][x]), fa = 1;
    if (!fa) work(son[0][x]);
    if (!fb) work(son[1][x]);
  } else {
    work(son[0][x]);
    work(son[1][x]);
  }
}
int read() {
  int xx = 0, ff = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') ff = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    xx = (xx << 1) + (xx << 3) + c - '0';
    c = getchar();
  }
  return xx * ff;
}
int main() {
  scanf("%d", &n);
  memset(ok, 1, sizeof ok);
  register int i;
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    if (s[1] == 'I') {
      a[++cnt] = i;
      v[i] = read();
    } else if (s[1] == 'N') {
      int x;
      x = read();
      son[0][i] = x;
      fa[x] = i;
      col[i] = 4;
      add(i, x);
    } else if (s[1] == 'A') {
      int x, y;
      x = read();
      y = read();
      son[0][i] = x;
      son[1][i] = y;
      fa[x] = i;
      fa[y] = i;
      col[i] = 1;
      add(i, x);
      add(i, y);
    } else if (s[1] == 'O') {
      int x, y;
      x = read();
      y = read();
      son[0][i] = x;
      son[1][i] = y;
      fa[x] = i;
      fa[y] = i;
      col[i] = 2;
      add(i, x);
      add(i, y);
    } else if (s[1] == 'X') {
      int x, y;
      x = read();
      y = read();
      son[0][i] = x;
      son[1][i] = y;
      fa[x] = i;
      fa[y] = i;
      col[i] = 3;
      add(i, x);
      add(i, y);
    }
  }
  dfs(1);
  work(1);
  for (int i = 1; i <= cnt; i++)
    if (!ok[a[i]])
      printf("%d", v[1]);
    else
      printf("%d", !v[1]);
  return 0;
}
