#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
struct node {
  int left, right, value;
  char type;
  bool change;
};
int n;
vector<node> g(N);
int dfsInit(int v) {
  if (g[v].type == 'I') return g[v].value;
  switch (g[v].type) {
    case 'A':
      g[v].value = dfsInit(g[v].left) & dfsInit(g[v].right);
      break;
    case 'O':
      g[v].value = dfsInit(g[v].left) | dfsInit(g[v].right);
      break;
    case 'X':
      g[v].value = dfsInit(g[v].left) ^ dfsInit(g[v].right);
      break;
    case 'N':
      g[v].value = !dfsInit(g[v].left);
      break;
  }
  return g[v].value;
}
void dfsSolve(int v) {
  if (!v) return;
  int L = g[v].left, R = g[v].right;
  if (g[v].change == false) {
    g[L].change = false;
    g[R].change = false;
    dfsSolve(L);
    dfsSolve(R);
    return;
  }
  switch (g[v].type) {
    case 'A':
      if (g[R].value == 1)
        g[L].change = true;
      else
        g[L].change = false;
      if (g[L].value == 1)
        g[R].change = true;
      else
        g[R].change = false;
      dfsSolve(L);
      dfsSolve(R);
      break;
    case 'O':
      if (g[R].value == 0)
        g[L].change = true;
      else
        g[L].change = false;
      if (g[L].value == 0)
        g[R].change = true;
      else
        g[R].change = false;
      dfsSolve(L);
      dfsSolve(R);
      break;
    case 'X':
      g[L].change = true;
      g[R].change = true;
      dfsSolve(L);
      dfsSolve(R);
      break;
    case 'N':
      g[L].change = true;
      dfsSolve(L);
      break;
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    char op[6];
    scanf("%s", &op);
    g[i].type = op[0];
    if (op[0] == 'I') {
      int v;
      scanf("%d", &v);
      g[i].value = v;
      g[i].left = 0;
      g[i].right = 0;
    } else if (op[0] == 'N') {
      int v;
      scanf("%d", &v);
      g[i].left = v;
      g[i].right = 0;
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      g[i].left = l;
      g[i].right = r;
    }
  }
  dfsInit(1);
  g[1].change = true;
  dfsSolve(1);
  for (int i = 1; i <= n; ++i) {
    if (g[i].type == 'I') {
      if (g[i].change == true)
        cout << !g[1].value;
      else
        cout << g[1].value;
    }
  }
}
