#include <bits/stdc++.h>
static long long gcd(long long x, long long y) {
  return y == 0 ? x : gcd(y, x % y);
}
static long long pwm(long long x, long long n, long long m) {
  long long r = 1;
  while (n) {
    if (n & 1) r = r * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return r;
}
struct vertex {
  char type;
  int in[2];
  bool val;
  bool change;
};
std::vector<vertex> g;
int n;
int dfs1(int v) {
  switch (g[v].type) {
    case 'A':
      g[v].val = (dfs1(g[v].in[0]) & dfs1(g[v].in[1]));
      break;
    case 'O':
      g[v].val = (dfs1(g[v].in[0]) | dfs1(g[v].in[1]));
      break;
    case 'X':
      g[v].val = (dfs1(g[v].in[0]) ^ dfs1(g[v].in[1]));
      break;
    case 'N':
      g[v].val = (!dfs1(g[v].in[0]));
      break;
  }
  return g[v].val;
}
void dfs2(int v) {
  if (g[v].change == false) {
    g[g[v].in[0]].change = false;
    g[g[v].in[1]].change = false;
  } else {
    switch (g[v].type) {
      case 'A':
        g[g[v].in[0]].change =
            g[v].val != (!g[g[v].in[0]].val & g[g[v].in[1]].val);
        g[g[v].in[1]].change =
            g[v].val != (g[g[v].in[0]].val & !g[g[v].in[1]].val);
        break;
      case 'O':
        g[g[v].in[0]].change =
            g[v].val != (!g[g[v].in[0]].val | g[g[v].in[1]].val);
        g[g[v].in[1]].change =
            g[v].val != (g[g[v].in[0]].val | !g[g[v].in[1]].val);
        break;
      case 'X':
        g[g[v].in[0]].change =
            g[v].val != (!g[g[v].in[0]].val ^ g[g[v].in[1]].val);
        g[g[v].in[1]].change =
            g[v].val != (g[g[v].in[0]].val ^ !g[g[v].in[1]].val);
        break;
      case 'N':
        g[g[v].in[0]].change = g[v].val != (!!g[g[v].in[0]].val);
        break;
      case 'I':
        break;
    }
  }
  switch (g[v].type) {
    case 'A':
    case 'O':
    case 'X':
      dfs2(g[v].in[0]);
      dfs2(g[v].in[1]);
      break;
    case 'N':
      dfs2(g[v].in[0]);
      break;
  }
}
int readInt() {
  int x = 0, c = 0;
  c = getchar();
  while (!(c >= '0' && c <= '9')) c = getchar();
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int readType() {
  int c = getchar();
  while (c <= 32) c = getchar();
  int type = c;
  while (c > 32) c = getchar();
  return type;
}
int solve() {
  int x, y;
  n = readInt();
  g.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    g[i].type = readType();
    switch (g[i].type) {
      case 'A':
      case 'O':
      case 'X':
        g[i].in[0] = readInt();
        g[i].in[1] = readInt();
        break;
      case 'N':
        g[i].in[0] = readInt();
        break;
      case 'I':
        g[i].val = readInt();
        break;
    }
  }
  dfs1(1);
  g[1].change = true;
  dfs2(1);
  char* ans = (char*)malloc(n + 2);
  int j = 0;
  for (int i = 1; i <= n; ++i) {
    if (g[i].type == 'I') {
      ans[j++] = '0' + (g[i].change ^ g[1].val);
    }
  }
  ans[j] = '\0';
  puts(ans);
  free(ans);
  return 0;
}
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  int t = 1;
  while (t--) solve();
}
