#include <bits/stdc++.h>
using namespace std;
const int mx = 1e6 + 10;
int n, m;
char s[mx][5];
int a[mx], b[mx], c[mx], tp[mx], ans[mx];
void dfs(int u) {
  if (tp[u] == 0)
    c[u] = a[u];
  else if (tp[u] == 1) {
    dfs(a[u]);
    c[u] = c[a[u]] ^ 1;
  } else {
    dfs(a[u]);
    dfs(b[u]);
    if (tp[u] == 2)
      c[u] = c[a[u]] & c[b[u]];
    else if (tp[u] == 3)
      c[u] = c[a[u]] | c[b[u]];
    else
      c[u] = c[a[u]] ^ c[b[u]];
  }
}
void dfs2(int u, int res, int res2) {
  if (tp[u] == 0) {
    if (c[u] == 1)
      ans[u] = res;
    else
      ans[u] = res2;
  } else if (tp[u] == 1) {
    dfs2(a[u], res2, res);
  } else {
    if (tp[u] == 2) {
      if (c[b[u]] == 1)
        dfs2(a[u], res, res2);
      else
        dfs2(a[u], res, res);
      if (c[a[u]] == 1)
        dfs2(b[u], res, res2);
      else
        dfs2(b[u], res, res);
    } else if (tp[u] == 3) {
      if (c[b[u]] == 1)
        dfs2(a[u], res2, res2);
      else
        dfs2(a[u], res, res2);
      if (c[a[u]] == 1)
        dfs2(b[u], res2, res2);
      else
        dfs2(b[u], res, res2);
    } else {
      if (c[b[u]] == 1)
        dfs2(a[u], res2, res);
      else
        dfs2(a[u], res, res2);
      if (c[a[u]] == 1)
        dfs2(b[u], res2, res);
      else
        dfs2(b[u], res, res2);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i]);
    if (s[i][0] == 'I' || s[i][0] == 'N') {
      scanf("%d", &a[i]);
      tp[i] = (s[i][0] == 'I' ? 0 : 1);
    } else {
      scanf("%d%d", &a[i], &b[i]);
      if (s[i][0] == 'A')
        tp[i] = 2;
      else if (s[i][0] == 'O')
        tp[i] = 3;
      else
        tp[i] = 4;
    }
  }
  dfs(1);
  dfs2(1, 0, 1);
  for (int i = 1; i <= n; ++i)
    if (!tp[i]) printf("%d", ans[i]);
}
