#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
static int N, son[MAXN][2], ans[MAXN], chg[MAXN];
static char op[MAXN][5];
int dfs0(int u) {
  if (!strcmp(op[u], "IN"))
    return ans[u] = son[u][0];
  else if (!strcmp(op[u], "NOT"))
    return ans[u] = !dfs0(son[u][0]);
  else if (!strcmp(op[u], "AND"))
    return ans[u] = dfs0(son[u][0]) & dfs0(son[u][1]);
  else if (!strcmp(op[u], "XOR"))
    return ans[u] = dfs0(son[u][0]) ^ dfs0(son[u][1]);
  else
    return ans[u] = dfs0(son[u][0]) | dfs0(son[u][1]);
}
void dfs(int u, bool change) {
  if (!strcmp(op[u], "IN")) {
    chg[u] = change;
    return;
  } else if (!strcmp(op[u], "NOT"))
    dfs(son[u][0], change);
  else if (!strcmp(op[u], "XOR"))
    dfs(son[u][0], change), dfs(son[u][1], change);
  else if (!strcmp(op[u], "AND")) {
    int &a = ans[son[u][0]], &b = ans[son[u][1]];
    dfs(son[u][0], (a && b) == (!a && b) ? false : change);
    dfs(son[u][1], (a && b) == (a && !b) ? false : change);
  } else {
    int &a = ans[son[u][0]], &b = ans[son[u][1]];
    dfs(son[u][0], (a || b) == (!a || b) ? false : change);
    dfs(son[u][1], (a || b) == (a || !b) ? false : change);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s%d", op[i], &son[i][0]);
    if (strcmp(op[i], "IN") && strcmp(op[i], "NOT")) scanf("%d", &son[i][1]);
  }
  dfs0(1);
  dfs(1, true);
  for (int i = 1; i <= N; i++)
    if (!strcmp(op[i], "IN")) printf("%d", chg[i] ? !ans[1] : ans[1]);
  puts("");
  return 0;
}
