#include <bits/stdc++.h>
using namespace std;
int ans[1000005];
int val[1000005];
int c[1000005];
vector<int> vec[1000005];
void dfs_1(int x) {
  for (int i = 0; i < vec[x].size(); i++) {
    dfs_1(vec[x][i]);
  }
  if (c[x] == 1)
    val[x] = val[vec[x][0]] & val[vec[x][1]];
  else if (c[x] == 2)
    val[x] = val[vec[x][0]] | val[vec[x][1]];
  else if (c[x] == 3)
    val[x] = val[vec[x][0]] ^ val[vec[x][1]];
  else if (c[x] == 4)
    val[x] = val[vec[x][0]] ^ 1;
}
void dfs_2(int x, int flag) {
  if (c[x] == 5) {
    ans[x] = val[1] ^ flag;
  } else {
    if (c[x] == 1) {
      int nx = vec[x][0];
      int ny = vec[x][1];
      if (val[ny] == 0)
        dfs_2(nx, min(flag, 0));
      else
        dfs_2(nx, min(flag, 1));
      if (val[nx] == 0)
        dfs_2(ny, min(flag, 0));
      else
        dfs_2(ny, min(flag, 1));
    } else {
      if (c[x] == 2) {
        int nx = vec[x][0];
        int ny = vec[x][1];
        if (val[ny] == 1)
          dfs_2(nx, min(flag, 0));
        else
          dfs_2(nx, min(flag, 1));
        if (val[nx] == 1)
          dfs_2(ny, min(flag, 0));
        else
          dfs_2(ny, min(flag, 1));
      } else {
        if (c[x] == 3) {
          int nx = vec[x][0];
          int ny = vec[x][1];
          dfs_2(nx, min(flag, 1));
          dfs_2(ny, min(flag, 1));
        } else {
          dfs_2(vec[x][0], min(flag, 1));
        }
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  char ord[7];
  for (int i = 1; i <= n; i++) {
    ans[i] = -1;
    scanf("%s", ord);
    int t1, t2;
    if (ord[0] == 'A') {
      c[i] = 1;
      scanf("%d%d", &t1, &t2);
      vec[i].push_back(t1);
      vec[i].push_back(t2);
    }
    if (ord[0] == 'O') {
      c[i] = 2;
      scanf("%d%d", &t1, &t2);
      vec[i].push_back(t1);
      vec[i].push_back(t2);
    }
    if (ord[0] == 'X') {
      c[i] = 3;
      scanf("%d%d", &t1, &t2);
      vec[i].push_back(t1);
      vec[i].push_back(t2);
    }
    if (ord[0] == 'N') {
      c[i] = 4;
      scanf("%d", &t1);
      vec[i].push_back(t1);
    }
    if (ord[0] == 'I') {
      c[i] = 5;
      scanf("%d", &t1);
      val[i] = t1;
    }
  }
  dfs_1(1);
  dfs_2(1, 1);
  for (int i = 1; i <= n; i++) {
    if (ans[i] != -1) printf("%d", ans[i]);
  }
  printf("\n");
  return 0;
}
