#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000001;
int d[maxn][2];
int ch[maxn][2];
int type[maxn];
int ret[maxn];
void dfs1(int u);
void dfs2(int u);
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char str[10];
    scanf("%s", str);
    if (!strcmp(str, "IN")) {
      scanf("%d", &ret[i]);
    } else if (!strcmp(str, "NOT")) {
      scanf("%d", &ch[i][0]);
      type[i] = 1;
    } else if (!strcmp(str, "AND")) {
      scanf("%d%d", &ch[i][0], &ch[i][1]);
      type[i] = 2;
    } else if (!strcmp(str, "OR")) {
      scanf("%d%d", &ch[i][0], &ch[i][1]);
      type[i] = 3;
    } else if (!strcmp(str, "XOR")) {
      scanf("%d%d", &ch[i][0], &ch[i][1]);
      type[i] = 4;
    }
  }
  dfs1(1);
  d[1][0] = 0;
  d[1][1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; i++) {
    if (type[i] == 0) {
      printf("%d", d[i][!ret[i]]);
    }
  }
  return 0;
}
void dfs1(int u) {
  if (type[u] == 0) return;
  if (type[u] == 1) {
    int v = ch[u][0];
    dfs1(v);
    ret[u] = !ret[v];
  } else {
    int v0 = ch[u][0];
    int v1 = ch[u][1];
    dfs1(v0);
    dfs1(v1);
    if (type[u] == 2) {
      ret[u] = ret[v0] & ret[v1];
    } else if (type[u] == 3) {
      ret[u] = ret[v0] | ret[v1];
    } else if (type[u] == 4) {
      ret[u] = ret[v0] ^ ret[v1];
    }
  }
}
void dfs2(int u) {
  if (type[u] == 0) {
    return;
  }
  if (type[u] == 1) {
    int v = ch[u][0];
    d[v][0] = d[u][1];
    d[v][1] = d[u][0];
    dfs2(v);
  } else {
    int v0 = ch[u][0];
    int v1 = ch[u][1];
    if (type[u] == 2) {
      d[v0][0] = 0;
      d[v0][1] = ret[v1] & 1;
      d[v1][0] = 0;
      d[v1][1] = ret[v0] & 1;
    } else if (type[u] == 3) {
      d[v0][0] = ret[v1];
      d[v0][1] = 1;
      d[v1][0] = ret[v0];
      d[v1][1] = 1;
    } else if (type[u] == 4) {
      d[v0][0] = ret[v1] ^ 0;
      d[v0][1] = ret[v1] ^ 1;
      d[v1][0] = ret[v0] ^ 0;
      d[v1][1] = ret[v0] ^ 1;
    }
    d[v0][0] = d[u][d[v0][0]];
    d[v0][1] = d[u][d[v0][1]];
    d[v1][0] = d[u][d[v1][0]];
    d[v1][1] = d[u][d[v1][1]];
    dfs2(v0);
    dfs2(v1);
  }
}
