#include <bits/stdc++.h>
using namespace std;
const int N = 1000004;
char s[N];
int b[N], ans[N];
int a[N][2], n;
void dfs1(int u) {
  if (s[u] == 'I') return;
  int x = a[u][0], y = a[u][1];
  dfs1(x);
  if (y) dfs1(y);
  if (s[u] == '&')
    b[u] = b[x] & b[y];
  else if (s[u] == '|')
    b[u] = b[x] | b[y];
  else if (s[u] == '^')
    b[u] = b[x] ^ b[y];
  else
    b[u] = !b[x];
}
void dfs2(int u) {
  if (s[u] == 'I') {
    ans[u] ^= 1;
    return;
  }
  int x = a[u][0], y = a[u][1];
  if (s[u] == '&') {
    if (!b[x] && !b[y])
      return;
    else if (b[x] && b[y]) {
      dfs2(x);
      dfs2(y);
    } else if (!b[x])
      dfs2(x);
    else
      dfs2(y);
  } else if (s[u] == '|') {
    if (b[x] && b[y])
      return;
    else if (!b[x] && !b[y]) {
      dfs2(x);
      dfs2(y);
    } else if (b[x])
      dfs2(x);
    else
      dfs2(y);
  } else if (s[u] == '^') {
    dfs2(x);
    dfs2(y);
  } else
    dfs2(x);
}
int main() {
  char t[14];
  int x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s %d", t, &x);
    if (t[0] == 'I')
      b[i] = x, s[i] = 'I';
    else if (t[0] == 'N')
      a[i][0] = x, s[i] = '!';
    else {
      scanf("%d", &y);
      if (t[0] == 'A')
        s[i] = '&';
      else if (t[0] == 'O')
        s[i] = '|';
      else
        s[i] = '^';
      a[i][0] = x;
      a[i][1] = y;
    }
  }
  dfs1(1);
  for (int i = 1; i <= n; i++)
    if (s[i] == 'I') ans[i] = b[1];
  dfs2(1);
  for (int i = 1; i <= n; i++)
    if (s[i] == 'I') printf("%d", ans[i]);
}
