#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int n;
int t[N], l[N], r[N], v[N];
int dp[N][2][2];
int d[N];
int Eval(int A, int B, int t) {
  if (t == 0) return A;
  if (t == 1) return !A;
  if (t == 2) return A && B;
  if (t == 3) return A || B;
  return A ^ B;
}
int DFS(int u) {
  if (l[u] == -1) return d[u] = v[u];
  if (r[u] == -1) return d[u] = !DFS(l[u]);
  int A = DFS(l[u]);
  int B = DFS(r[u]);
  if (t[u] == 2) return d[u] = A && B;
  if (t[u] == 3) return d[u] = A || B;
  return d[u] = A ^ B;
}
int res[N];
void calc(int u, int p, int other) {
  if (l[u] == -1) {
    res[u] = dp[p][!v[u]][other];
    return;
  }
  for (int a = 0; a < 2; ++a)
    for (int b = 0; b < 2; ++b) {
      if (p == -1)
        dp[u][a][b] = Eval(a, b, t[u]);
      else
        dp[u][a][b] = dp[p][Eval(a, b, t[u])][other];
    }
  if (r[u] == -1)
    calc(l[u], u, 1);
  else {
    calc(l[u], u, d[r[u]]);
    calc(r[u], u, d[l[u]]);
  }
}
int main() {
  scanf("%d", &n);
  char s[8];
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    l[i] = r[i] = -1;
    if (s[0] == 'I') {
      t[i] = 0;
      scanf("%d", &v[i]);
    } else if (s[0] == 'N') {
      t[i] = 1;
      scanf("%d", &l[i]);
      --l[i];
    } else {
      if (s[0] == 'A')
        t[i] = 2;
      else if (s[0] == 'O')
        t[i] = 3;
      else if (s[0] == 'X')
        t[i] = 4;
      scanf("%d%d", &l[i], &r[i]);
      --l[i];
      --r[i];
    }
  }
  memset(res, -1, sizeof(res));
  DFS(0);
  calc(0, -1, 1);
  for (int i = 0; i < n; ++i)
    if (res[i] != -1) printf("%d", res[i]);
  return 0;
}
