#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
struct vertex {
  char type;
  vector<int> in;
  bool val;
  bool change;
};
int n;
vector<vertex> g;
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)
    for (int i = 0; i < g[v].in.size(); i++) g[g[v].in[i]].change = false;
  else
    switch (g[v].type) {
      case 'A':
        if (g[v].val == (!g[g[v].in[0]].val & g[g[v].in[1]].val))
          g[g[v].in[0]].change = false;
        else
          g[g[v].in[0]].change = true;
        if (g[v].val == (g[g[v].in[0]].val & !g[g[v].in[1]].val))
          g[g[v].in[1]].change = false;
        else
          g[g[v].in[1]].change = true;
        break;
      case 'O':
        if (g[v].val == (!g[g[v].in[0]].val | g[g[v].in[1]].val))
          g[g[v].in[0]].change = false;
        else
          g[g[v].in[0]].change = true;
        if (g[v].val == (g[g[v].in[0]].val | !g[g[v].in[1]].val))
          g[g[v].in[1]].change = false;
        else
          g[g[v].in[1]].change = true;
        break;
      case 'X':
        if (g[v].val == (!g[g[v].in[0]].val ^ g[g[v].in[1]].val))
          g[g[v].in[0]].change = false;
        else
          g[g[v].in[0]].change = true;
        if (g[v].val == (g[g[v].in[0]].val ^ !g[g[v].in[1]].val))
          g[g[v].in[1]].change = false;
        else
          g[g[v].in[1]].change = true;
        break;
      case 'N':
        if (g[v].val == (!!g[g[v].in[0]].val))
          g[g[v].in[0]].change = false;
        else
          g[g[v].in[0]].change = true;
        break;
    }
  for (int i = 0; i < g[v].in.size(); i++) dfs2(g[v].in[i]);
}
int main() {
  scanf("%d", &n);
  g.resize(n);
  for (int i = 0; i < n; i++) {
    char c[4];
    scanf("%s", c);
    g[i].type = c[0];
    int x;
    switch (g[i].type) {
      case 'I':
        scanf("%d", &x);
        g[i].val = x;
        break;
      case 'N':
        scanf("%d", &x);
        g[i].in.push_back(x - 1);
        break;
      default:
        scanf("%d", &x);
        g[i].in.push_back(x - 1);
        scanf("%d", &x);
        g[i].in.push_back(x - 1);
        break;
    }
  }
  dfs1(0);
  g[0].change = true;
  dfs2(0);
  for (int i = 0; i < n; i++)
    if (g[i].type == 'I') printf("%d", g[0].val ^ g[i].change);
}
