#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, a[1000010], b[1000010], son[1000010][2];
int dp[1000010][2];
char op[100];
void dfs(int u) {
  if (b[u] == 5) return;
  if (b[u] == 4) {
    dfs(son[u][0]);
    a[u] = !a[son[u][0]];
    return;
  }
  dfs(son[u][0]);
  dfs(son[u][1]);
  if (b[u] == 1)
    a[u] = a[son[u][0]] & a[son[u][1]];
  else if (b[u] == 2)
    a[u] = a[son[u][0]] | a[son[u][1]];
  else
    a[u] = a[son[u][0]] ^ a[son[u][1]];
  return;
}
void solve() {
  dfs(1);
  queue<int> q;
  q.push(1);
  dp[1][0] = 0;
  dp[1][1] = 1;
  int u, v1, v2;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    if (b[u] == 5) continue;
    if (b[u] == 4) {
      v1 = son[u][0];
      dp[v1][a[v1]] = dp[u][a[u]];
      dp[v1][!a[v1]] = dp[u][!a[u]];
      q.push(v1);
      continue;
    }
    v1 = son[u][0];
    v2 = son[u][1];
    if (b[u] == 1) {
      dp[v1][0] = dp[v2][0] = dp[v1][1] = dp[v2][1] = dp[u][0];
      if (a[v2] == 1) dp[v1][1] = dp[u][1];
      if (a[v1] == 1) dp[v2][1] = dp[u][1];
    } else if (b[u] == 2) {
      dp[v1][1] = dp[v2][1] = dp[v1][0] = dp[v2][0] = dp[u][1];
      if (a[v2] == 0) dp[v1][0] = dp[u][0];
      if (a[v1] == 0) dp[v2][0] = dp[u][0];
    } else {
      if (a[v1] == 0) {
        dp[v2][0] = dp[u][0];
        dp[v2][1] = dp[u][1];
      } else {
        dp[v2][0] = dp[u][1];
        dp[v2][1] = dp[u][0];
      }
      if (a[v2] == 0) {
        dp[v1][0] = dp[u][0];
        dp[v1][1] = dp[u][1];
      } else {
        dp[v1][0] = dp[u][1];
        dp[v1][1] = dp[u][0];
      }
    }
    q.push(v1);
    q.push(v2);
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 1, u, v; i <= n; ++i) {
    scanf("%s", op);
    if (op[0] == 'I') {
      scanf("%d", &u);
      a[i] = u;
      b[i] = 5;
    } else if (op[0] == 'N') {
      scanf("%d", &u);
      son[i][0] = u;
      b[i] = 4;
    } else {
      scanf("%d%d", &u, &v);
      son[i][0] = u;
      son[i][1] = v;
      if (op[0] == 'A') b[i] = 1;
      if (op[0] == 'O') b[i] = 2;
      if (op[0] == 'X') b[i] = 3;
    }
  }
  solve();
  for (int i = 1; i <= n; ++i)
    if (b[i] == 5) printf("%d", dp[i][!a[i]]);
  printf("\n");
  return 0;
}
