#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(int x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const int maxn = 1e6 + 10;
const int inf = 1e9;
const double eps = 1e-8;
const int mod = 1e9 + 7;
int a[maxn], n, m, c[maxn][2], f[maxn], g[maxn], op[maxn];
char s[5];
void dfs(int x) {
  if (c[x][0]) dfs(c[x][0]);
  if (c[x][1]) dfs(c[x][1]);
  int a = f[c[x][0]], b = f[c[x][1]];
  if (op[x] == 1)
    f[x] = a & b;
  else if (op[x] == 2)
    f[x] = a | b;
  else if (op[x] == 3)
    f[x] = a ^ b;
  else if (op[x] == 4)
    f[x] = !a;
}
void dp(int x, int fa, int e) {
  if (x != 1) {
    int o = op[fa];
    if (o == 1) {
      if ((f[e] & (!f[x])) != f[fa])
        g[x] = g[fa];
      else
        g[x] = f[1];
    } else if (o == 2) {
      if ((f[e] | (!f[x])) != f[fa])
        g[x] = g[fa];
      else
        g[x] = f[1];
    } else if (o == 3) {
      if ((f[e] ^ (!f[x])) != f[fa])
        g[x] = g[fa];
      else
        g[x] = f[1];
    } else if (o == 4)
      g[x] = g[fa];
  }
  if (c[x][0]) dp(c[x][0], x, c[x][1]);
  if (c[x][1]) dp(c[x][1], x, c[x][0]);
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    if (s[1] == 'A')
      op[i] = 1;
    else if (s[1] == 'O')
      op[i] = 2;
    else if (s[1] == 'X')
      op[i] = 3;
    else if (s[1] == 'N')
      op[i] = 4;
    else
      op[i] = 5;
    if (op[i] <= 3)
      read(c[i][0]), read(c[i][1]);
    else if (op[i] == 4)
      read(c[i][0]);
    else
      read(f[i]);
  }
  dfs(1);
  g[1] = !f[1];
  dp(1, 0, 0);
  for (int i = 1; i <= n; i++)
    if (op[i] == 5) putchar(g[i] + '0');
  return 0;
}
