#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, val[maxn], outdeg[maxn], w[maxn];
vector<int> g[maxn];
int ans[maxn][2], par[maxn];
char s[10];
void dfs(int u) {
  if (g[u].size() == 0) {
    w[u] = val[u];
    return;
  }
  if (g[u].size() == 1) {
    par[g[u][0]] = u;
    dfs(g[u][0]);
    w[u] = 1 ^ w[g[u][0]];
    return;
  }
  int ls = g[u][0];
  int rs = g[u][1];
  par[ls] = u;
  par[rs] = u;
  dfs(ls);
  dfs(rs);
  if (val[u] == 2) w[u] = w[ls] & w[rs];
  if (val[u] == 3) w[u] = w[ls] | w[rs];
  if (val[u] == 4) w[u] = w[ls] ^ w[rs];
}
int solve(int v, int t) {
  if (ans[v][t] != -1) return ans[v][t];
  int u = par[v];
  if (g[u].size() == 1) ans[v][t] = solve(u, t ^ 1);
  if (g[u].size() == 2) {
    int ls = g[u][0];
    int rs = g[u][1];
    if (ls == v) swap(ls, rs);
    if (val[u] == 2) ans[v][t] = solve(u, w[ls] & t);
    if (val[u] == 3) ans[v][t] = solve(u, w[ls] | t);
    if (val[u] == 4) ans[v][t] = solve(u, w[ls] ^ t);
  }
  return ans[v][t];
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'I')
      scanf("%d", &val[i]);
    else if (s[0] == 'N') {
      scanf("%d", &x);
      g[i].push_back(x);
      outdeg[i]++;
    } else {
      scanf("%d%d", &x, &y), g[i].push_back(x), g[i].push_back(y);
      outdeg[i]++;
      if (s[0] == 'A') val[i] = 2;
      if (s[0] == 'O') val[i] = 3;
      if (s[0] == 'X') val[i] = 4;
    }
  }
  dfs(1);
  for (int i = 1; i <= n; i++) ans[i][w[i]] = w[1], ans[i][w[i] ^ 1] = -1;
  ans[1][0] = 0, ans[1][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (!outdeg[i]) {
      printf("%d", solve(i, w[i] ^ 1));
    }
  }
  printf("\n");
  return 0;
}
