#include <bits/stdc++.h>
using namespace std;
int n, val[1000010], a[1000010][2], ty[1000010], ans[1000010];
char s[10];
void dfs1(int now) {
  if (ty[now] == 1)
    dfs1(a[now][0]), dfs1(a[now][1]),
        val[now] = val[a[now][0]] & val[a[now][1]];
  if (ty[now] == 2)
    dfs1(a[now][0]), dfs1(a[now][1]),
        val[now] = val[a[now][0]] | val[a[now][1]];
  if (ty[now] == 3)
    dfs1(a[now][0]), dfs1(a[now][1]),
        val[now] = val[a[now][0]] ^ val[a[now][1]];
  if (ty[now] == 4) dfs1(a[now][0]), val[now] = !val[a[now][0]];
}
void dfs2(int now, int flag) {
  if (ty[now] == 5) {
    ans[now] = val[1] ^ flag;
    return;
  }
  int x = a[now][0], y = a[now][1];
  if (ty[now] == 1) {
    if ((val[x] == 0 && val[y] == 0) || (val[x] == 1 && val[y] == 0))
      dfs2(x, min(flag, 0));
    else
      dfs2(x, min(flag, 1));
    if ((val[x] == 0 && val[y] == 0) || (val[x] == 0 && val[y] == 1))
      dfs2(y, min(flag, 0));
    else
      dfs2(y, min(flag, 2));
  }
  if (ty[now] == 2) {
    if ((val[x] == 1 && val[y] == 1) || (val[x] == 0 && val[y] == 1))
      dfs2(x, min(flag, 0));
    else
      dfs2(x, min(flag, 1));
    if ((val[x] == 1 && val[y] == 1) || (val[x] == 1 && val[y] == 0))
      dfs2(y, min(flag, 0));
    else
      dfs2(y, min(flag, 2));
  }
  if (ty[now] == 3) {
    dfs2(x, min(flag, 1));
    dfs2(y, min(flag, 1));
  }
  if (ty[now] == 4) {
    dfs2(x, min(flag, 1));
  }
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    if (s[1] == 'A') {
      ty[i] = 1;
      scanf("%d%d", &x, &y);
      a[i][0] = x;
      a[i][1] = y;
    }
    if (s[1] == 'O') {
      ty[i] = 2;
      scanf("%d%d", &x, &y);
      a[i][0] = x;
      a[i][1] = y;
    }
    if (s[1] == 'X') {
      ty[i] = 3;
      scanf("%d%d", &x, &y);
      a[i][0] = x;
      a[i][1] = y;
    }
    if (s[1] == 'N') {
      ty[i] = 4;
      scanf("%d", &x);
      a[i][0] = x;
    }
    if (s[1] == 'I') {
      ty[i] = 5;
      scanf("%d", &x);
      val[i] = x;
    }
  }
  dfs1(1);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++)
    if (ty[i] == 5) printf("%d", ans[i]);
  puts("");
  return 0;
}
