#include <bits/stdc++.h>
using namespace std;
inline int get_op(char *s) {
  if (s[0] == 'A') return 1;
  if (s[0] == 'O') return 2;
  if (s[0] == 'X') return 3;
  if (s[0] == 'N') return 4;
  if (s[0] == 'I') return 5;
  return 0;
}
inline bool calc(bool a, bool b, int op) {
  if (op == 1) return a & b;
  if (op == 2) return a | b;
  if (op == 3) return a ^ b;
  return 1;
}
const int maxn = int(1e6) + 111;
int n;
int indge[maxn];
struct Node {
  bool val, imp;
  int op, ls, rs;
  Node() { ls = rs = 0; }
} node[maxn];
bool dfs1(int k) {
  if (node[k].op == 5) return node[k].val;
  Node &ls = node[(node[k].ls)], &rs = node[(node[k].rs)];
  if (node[k].op <= 3) {
    node[k].val = calc(dfs1((node[k].ls)), dfs1((node[k].rs)), node[k].op);
    if (calc(ls.val ^ 1, rs.val, node[k].op) != node[k].val) ls.imp = true;
    if (calc(ls.val, rs.val ^ 1, node[k].op) != node[k].val) rs.imp = true;
  } else if (node[k].op == 4) {
    node[k].val = !dfs1((node[k].ls));
    ls.imp = true;
  }
  return node[k].val;
}
void dfs2(int k) {
  if (node[k].op == 5) return;
  if (!node[k].imp) node[(node[k].ls)].imp = node[(node[k].rs)].imp = false;
  if ((node[k].ls)) dfs2((node[k].ls));
  if ((node[k].rs)) dfs2((node[k].rs));
  return;
}
int main() {
  scanf("%d", &n);
  register int i, x, y, ty;
  char s[5];
  for (i = 1; i <= n; ++i) {
    scanf("%s%d", s, &x);
    node[i].op = ty = get_op(s);
    if (ty == 1 || ty == 2 || ty == 3) {
      scanf("%d", &y);
      node[i].ls = x, node[i].rs = y;
      indge[x]++, indge[y]++;
    } else if (ty == 4)
      node[i].ls = x, indge[x]++;
    else if (ty == 5)
      node[i].val = x;
  }
  int root = 0;
  for (i = 1; i <= n; ++i)
    if (!indge[i]) root = i;
  node[root].imp = true;
  dfs1(root);
  dfs2(root);
  for (i = 1; i <= n; ++i)
    if (node[i].op == 5) printf("%d", node[root].val ^ node[i].imp);
  return 0;
}
