#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, t = 1;
  register char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return x * t;
}
int n;
char ch[20];
struct Line {
  int v, next;
} e[1001000 << 1];
int h[1001000], cnt = 1;
inline void Add(int u, int v) {
  e[cnt] = (Line){v, h[u]};
  h[u] = cnt++;
}
int p[1001000], c[1001000], fa[1001000], tag[1001000];
void dfs(int u, int ff) {
  fa[u] = ff;
  int son[5], tot = 0;
  for (int i = h[u]; i; i = e[i].next)
    if (e[i].v != ff) son[++tot] = e[i].v, dfs(e[i].v, u);
  ;
  if (p[u] == 0) return;
  if (p[u] == 1) c[u] = c[son[1]] & c[son[2]];
  if (p[u] == 2) c[u] = c[son[1]] ^ 1;
  if (p[u] == 3) c[u] = c[son[1]] | c[son[2]];
  if (p[u] == 4) c[u] = c[son[1]] ^ c[son[2]];
  if (p[u] == 1) {
    int x = son[1], y = son[2];
    if (c[x] == 0) tag[y] = 1;
    if (c[y] == 0) tag[x] = 1;
  }
  if (p[u] == 3) {
    int x = son[1], y = son[2];
    if (c[x] == 1) tag[y] = 1;
    if (c[y] == 1) tag[x] = 1;
  }
}
void dfs2(int u, int ff) {
  tag[u] |= tag[ff];
  for (int i = h[u]; i; i = e[i].next)
    if (e[i].v != ff) dfs2(e[i].v, u);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", ch);
    if (ch[0] == 'A') {
      p[i] = 1;
      int u = read(), v = read();
      Add(i, u);
      Add(i, v);
      Add(u, i);
      Add(v, i);
    }
    if (ch[0] == 'I') {
      p[i] = 0;
      c[i] = read();
    }
    if (ch[0] == 'N') {
      p[i] = 2;
      int u = read();
      Add(i, u);
      Add(u, i);
    }
    if (ch[0] == 'O') {
      p[i] = 3;
      int u = read(), v = read();
      Add(i, u);
      Add(i, v);
      Add(u, i);
      Add(v, i);
    }
    if (ch[0] == 'X') {
      p[i] = 4;
      int u = read(), v = read();
      Add(i, u);
      Add(i, v);
      Add(u, i);
      Add(v, i);
    }
  }
  dfs(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i)
    if (p[i] == 0)
      if (tag[i]) {
        putchar(48 + c[1]);
      } else
        putchar(48 + c[1] ^ 1);
  puts("");
  return 0;
}
