#include <bits/stdc++.h>
using namespace std;
int n, a[1000005], l[1000005], r[1000005], b[1000005], c[1000005], x, y;
char s[10];
void dfs(int x) {
  if (b[x] == 0)
    return;
  else if (b[x] == 1)
    dfs(l[x]), a[x] = a[l[x]] ^ 1;
  else if (b[x] == 4)
    dfs(l[x]), dfs(r[x]), a[x] = a[l[x]] ^ a[r[x]];
  else
    dfs(l[x]), dfs(r[x]),
        a[x] = (b[x] == 2) ? (a[l[x]] | a[r[x]]) : (a[l[x]] & a[r[x]]);
}
void Dfs(int x) {
  c[x] = 1;
  if (b[x] == 0)
    return;
  else if (b[x] == 1)
    Dfs(l[x]);
  else if (b[x] == 2) {
    if (a[l[x]] == 1 && a[r[x]] != 1) Dfs(l[x]);
    if (a[r[x]] == 1 && a[l[x]] != 1) Dfs(r[x]);
    if (a[l[x]] == 0 && a[r[x]] == 0) Dfs(l[x]), Dfs(r[x]);
  } else if (b[x] == 3) {
    if (a[l[x]] == 1 && a[r[x]] != 1) Dfs(r[x]);
    if (a[r[x]] == 1 && a[l[x]] != 1) Dfs(l[x]);
    if (a[l[x]] == 1 && a[r[x]] == 1) Dfs(l[x]), Dfs(r[x]);
  } else
    Dfs(l[x]), Dfs(r[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'I')
      scanf("%d", &a[i]);
    else if (s[0] == 'N')
      scanf("%d", &x), b[i] = 1, l[i] = x;
    else if (s[0] == 'O')
      scanf("%d%d", &x, &y), b[i] = 2, l[i] = x, r[i] = y;
    else if (s[0] == 'A')
      scanf("%d%d", &x, &y), b[i] = 3, l[i] = x, r[i] = y;
    else if (s[0] == 'X')
      scanf("%d%d", &x, &y), b[i] = 4, l[i] = x, r[i] = y;
  }
  dfs(1);
  Dfs(1);
  for (int i = 1; i <= n; i++)
    if (b[i] == 0) printf("%d", c[i] ^ a[1]);
}
