#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int lson[N], rson[N], w[N], ans[N], n;
char s[N][5];
void dfs1(int x) {
  if (s[x][0] == 'I') return;
  int ls = lson[x], rs = rson[x];
  if (s[x][0] == 'A' || s[x][0] == 'O' || s[x][0] == 'X') {
    dfs1(ls);
    dfs1(rs);
    if (s[x][0] == 'A')
      w[x] = (w[ls] & w[rs]);
    else if (s[x][0] == 'O')
      w[x] = (w[ls] | w[rs]);
    else if (s[x][0] == 'X')
      w[x] = (w[ls] ^ w[rs]);
  } else if (s[x][0] == 'N') {
    dfs1(ls);
    w[x] = (!w[ls]);
  }
}
void dfs2(int x) {
  if (s[x][0] == 'I') {
    ans[x] = 1;
    return;
  }
  int ls = lson[x], rs = rson[x];
  if (s[x][0] == 'A') {
    if (((w[ls] ^ 1) & w[rs]) == (w[x] ^ 1)) dfs2(ls);
    if ((w[ls] & (w[rs] ^ 1)) == (w[x] ^ 1)) dfs2(rs);
  } else if (s[x][0] == 'O') {
    if (((w[ls] ^ 1) | w[rs]) == (w[x] ^ 1)) dfs2(ls);
    if ((w[ls] | (w[rs] ^ 1)) == (w[x] ^ 1)) dfs2(rs);
  } else if (s[x][0] == 'X') {
    if (((w[ls] ^ 1) ^ w[rs]) == (w[x] ^ 1)) dfs2(ls);
    if ((w[ls] ^ (w[rs] ^ 1)) == (w[x] ^ 1)) dfs2(rs);
  } else
    dfs2(ls);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    if (s[i][0] == 'I')
      scanf("%d", &w[i]);
    else if (s[i][0] == 'A' || s[i][0] == 'O' || s[i][0] == 'X')
      scanf("%d%d", &lson[i], &rson[i]);
    else if (s[i][0] == 'N')
      scanf("%d", &lson[i]);
  }
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; i++)
    if (s[i][0] == 'I') printf("%d", w[1] ^ ans[i]);
  puts("");
  return 0;
}
