#include <bits/stdc++.h>
using namespace std;
char op[1000009][5];
int bit[1000009][2];
int value[1000009];
bool flag[1000009];
int dfs(int u) {
  int& ans = value[u];
  if (op[u][0] == 'I') {
  } else if (op[u][0] == 'N') {
    ans = 1 - dfs(bit[u][0]);
  } else if (op[u][0] == 'A') {
    ans = dfs(bit[u][0]) * dfs(bit[u][1]);
  } else if (op[u][0] == 'O') {
    ans = max(dfs(bit[u][0]), dfs(bit[u][1]));
  } else if (op[u][0] == 'X') {
    ans = dfs(bit[u][0]) ^ dfs(bit[u][1]);
  } else {
    int k = 0;
    int temp = 1 / k;
  }
  return ans;
}
void mark(int u, int p) {
  if (u == -1) return;
  if (p == -1) {
    flag[u] = true;
    mark(bit[u][0], u);
    mark(bit[u][1], u);
    return;
  }
  if (op[p][0] == 'I') {
    int k = 0;
    int temp = 1 / k;
    return;
  } else if (op[p][0] == 'N') {
    flag[u] = flag[p];
  } else if (op[p][0] == 'A') {
    int o = bit[p][0] ^ bit[p][1] ^ u;
    if (value[o] == 1)
      flag[u] = flag[p];
    else
      flag[u] = false;
  } else if (op[p][0] == 'O') {
    int o = bit[p][0] ^ bit[p][1] ^ u;
    if (value[o] == 1)
      flag[u] = false;
    else
      flag[u] = flag[p];
  } else {
    flag[u] = flag[p];
  }
  mark(bit[u][0], u);
  mark(bit[u][1], u);
}
char all_ans[1000009];
int main() {
  int n;
  scanf("%d", &n);
  memset(bit, -1, sizeof(bit));
  vector<int> ins;
  for (int i = 1; i <= n; i++) {
    scanf("%s", op[i]);
    if (op[i][0] == 'N') {
      scanf("%d", &bit[i][0]);
    } else if (op[i][0] == 'I') {
      ins.push_back(i);
      scanf("%d", &value[i]);
    } else {
      scanf("%d %d", &bit[i][0], &bit[i][1]);
    }
  }
  int output = dfs(1);
  mark(1, -1);
  all_ans[ins.size()] = '\0';
  int my;
  for (int i = 0; i < (int)ins.size(); i++) {
    if (flag[ins[i]])
      my = 1 - output;
    else
      my = output;
    all_ans[i] = my + '0';
  }
  printf("%s", all_ans);
}
