#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
char type[N][5];
bool get(int cur, int x0, int x1) {
  if (type[cur][0] == 'A') return (x0 & x1);
  if (type[cur][0] == 'O') return (x0 | x1);
  if (type[cur][0] == 'X') return (x0 ^ x1);
  return (!x0);
}
int res[N][2];
int init[N];
int L[N], R[N];
int n;
void dfs(int cur) {
  if (type[cur][0] == 'I') return;
  if (cur == 0) {
    res[cur][0] = 0;
    res[cur][1] = 1;
  }
  if (type[cur][0] == 'N') {
    res[L[cur]][0] = res[cur][1];
    res[L[cur]][1] = res[cur][0];
    dfs(L[cur]);
  } else {
    res[L[cur]][0] = res[cur][get(cur, 0, init[R[cur]])];
    res[L[cur]][1] = res[cur][get(cur, 1, init[R[cur]])];
    res[R[cur]][0] = res[cur][get(cur, init[L[cur]], 0)];
    res[R[cur]][1] = res[cur][get(cur, init[L[cur]], 1)];
    dfs(L[cur]);
    dfs(R[cur]);
  }
}
void fillInit(int cur) {
  if (L[cur] == -1) return;
  fillInit(L[cur]);
  if (R[cur] == -1)
    init[cur] = !init[L[cur]];
  else {
    fillInit(R[cur]);
    init[cur] = get(cur, init[L[cur]], init[R[cur]]);
  }
}
int main() {
  scanf("%d", &n);
  memset(L, -1, sizeof L);
  memset(R, -1, sizeof R);
  for (int i = 0; i < n; ++i) {
    scanf(" %s", type[i]);
    if (type[i][0] == 'I') {
      scanf("%d", &init[i]);
      continue;
    }
    scanf("%d", &L[i]);
    L[i]--;
    if (type[i][0] == 'N') continue;
    scanf("%d", &R[i]);
    R[i]--;
  }
  fillInit(0);
  dfs(0);
  for (int i = 0; i < n; ++i)
    if (type[i][0] == 'I') {
      printf("%d", res[i][init[i] ^ 1]);
    }
}
