#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 100;
int n, l, r;
char str[maxn][10];
int num[maxn], Y[maxn][2];
vector<int> G[maxn];
void dfs1(int x) {
  int len = G[x].size();
  for (int i = 0; i < len; ++i) {
    dfs1(G[x][i]);
  }
  switch (str[x][0]) {
    case 'A':
      num[x] = num[G[x][0]] & num[G[x][1]];
      break;
    case 'O':
      num[x] = num[G[x][0]] | num[G[x][1]];
      break;
    case 'X':
      num[x] = num[G[x][0]] ^ num[G[x][1]];
      break;
    case 'N':
      num[x] = 1 - num[G[x][0]];
      break;
    default:
      break;
  }
}
void dfs2(int x) {
  int len = G[x].size();
  for (int i = 0; i < len; ++i) {
    int xx = 1 - num[G[x][i]];
    switch (str[x][0]) {
      case 'A':
        Y[G[x][i]][xx] = Y[x][xx & num[G[x][1 - i]]];
        break;
      case 'O':
        Y[G[x][i]][xx] = Y[x][xx | num[G[x][1 - i]]];
        break;
      case 'X':
        Y[G[x][i]][xx] = Y[x][xx ^ num[G[x][1 - i]]];
        break;
      case 'N':
        Y[G[x][i]][xx] = Y[x][1 - xx];
        break;
      default:
        break;
    }
    dfs2(G[x][i]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) {
      num[i] = -1;
      G[i].clear();
      scanf("%s", str[i]);
      if (str[i][0] == 'I') {
        scanf("%d", &num[i]);
      } else if (str[i][0] == 'A' || str[i][0] == 'O' || str[i][0] == 'X') {
        scanf("%d%d", &l, &r);
        G[i].push_back(l);
        G[i].push_back(r);
      } else if (str[i][0] == 'N') {
        scanf("%d", &l);
        G[i].push_back(l);
      }
    }
    dfs1(1);
    for (int i = 1; i <= n; ++i) {
      Y[i][num[i]] = num[1];
    }
    Y[1][1 - num[1]] = 1 - num[1];
    dfs2(1);
    for (int i = 1; i <= n; ++i) {
      if (str[i][0] == 'I') {
        printf("%d", Y[i][1 - num[i]]);
      }
    }
    printf("\n");
  }
  return 0;
}
