#include <bits/stdc++.h>
int n, son[1000005][2], typ[1000005], fa[1000005][21];
bool f[1000005][2][21];
int val[1000005];
char s[105];
void dfs1(int u) {
  if (son[u][0]) dfs1(son[u][0]);
  if (son[u][1]) dfs1(son[u][1]);
  if (typ[u] == 1) val[u] = val[son[u][0]] & val[son[u][1]];
  if (typ[u] == 2) val[u] = val[son[u][0]] | val[son[u][1]];
  if (typ[u] == 3) val[u] = val[son[u][0]] ^ val[son[u][1]];
  if (typ[u] == 4) val[u] = val[son[u][0]] ^ 1;
}
void dfs2(int u) {
  if (son[u][0]) fa[son[u][0]][0] = u, dfs2(son[u][0]);
  if (son[u][1]) fa[son[u][1]][0] = u, dfs2(son[u][1]);
  if (typ[u] == 1)
    f[son[u][0]][1][0] = val[son[u][1]], f[son[u][1]][1][0] = val[son[u][0]];
  if (typ[u] == 2)
    f[son[u][0]][1][0] = f[son[u][1]][1][0] = 1,
    f[son[u][0]][0][0] = val[son[u][1]], f[son[u][1]][0][0] = val[son[u][0]];
  if (typ[u] == 3) {
    f[son[u][0]][0][0] = val[son[u][1]], f[son[u][1]][0][0] = val[son[u][0]];
    f[son[u][0]][1][0] = val[son[u][1]] ^ 1,
    f[son[u][1]][1][0] = val[son[u][0]] ^ 1;
  }
  if (typ[u] == 4) f[son[u][0]][0][0] = 1, f[son[u][0]][1][0] = 0;
}
int solve(int x, int val) {
  for (int i = 20; ~i; i--)
    if (fa[x][i]) val = f[x][val][i], x = fa[x][i];
  return val;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'A') scanf("%d%d", &son[i][0], &son[i][1]), typ[i] = 1;
    if (s[0] == 'O') scanf("%d%d", &son[i][0], &son[i][1]), typ[i] = 2;
    if (s[0] == 'X') scanf("%d%d", &son[i][0], &son[i][1]), typ[i] = 3;
    if (s[0] == 'N') scanf("%d", &son[i][0]), typ[i] = 4;
    if (s[0] == 'I') scanf("%d", &val[i]);
  }
  dfs1(1), dfs2(1);
  for (int j = 1; j < 21; j++)
    for (int i = 1; i <= n; i++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
      f[i][0][j] = f[fa[i][j - 1]][f[i][0][j - 1]][j - 1];
      f[i][1][j] = f[fa[i][j - 1]][f[i][1][j - 1]][j - 1];
    }
  for (int i = 1; i <= n; i++)
    if (!typ[i]) printf("%d", solve(i, val[i] ^ 1));
}
