#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 32;
int type[maxn];
int n;
int head[maxn];
int va[maxn];
int tot;
vector<int> E[maxn];
int fa[maxn];
int leaf[maxn];
int dp[maxn];
void dfs(int u, int fa) {
  if (type[u] == 2) {
    dp[u] = va[u];
    return;
  }
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    dfs(v, u);
  }
  if (type[u] == 1) {
    dp[u] = dp[E[u][0]] & dp[E[u][1]];
  } else if (type[u] == 4) {
    dp[u] = !dp[E[u][0]];
  } else if (type[u] == 3) {
    dp[u] = dp[E[u][0]] ^ dp[E[u][1]];
  } else if (type[u] = 5) {
    dp[u] = dp[E[u][0]] | dp[E[u][1]];
  }
}
int dp2[maxn];
void dfs2(int u, int falg) {
  if (type[u] == 2) {
    dp2[u] = falg;
    return;
  }
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    if (type[u] == 1) {
      if (dp[v] == 1 && dp[E[u][i ^ 1]] == 1) {
        dfs2(v, 1 && falg);
      } else if (dp[v] == 0 && dp[E[u][i ^ 1]] == 1) {
        dfs2(v, 1 && falg);
      } else {
        dfs2(v, 0 && falg);
      }
    } else if (type[u] == 4) {
      dfs2(v, 1 && falg);
    } else if (type[u] == 3) {
      dfs2(v, 1 && falg);
    } else if (type[u] = 5) {
      if (dp[v] == 1 && dp[E[u][i ^ 1]] == 0) {
        dfs2(v, 1 && falg);
      } else if (dp[v] == 0 && dp[E[u][i ^ 1]] == 0) {
        dfs2(v, 1 && falg);
      } else {
        dfs2(v, 0 && falg);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  char s[10];
  int p = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      type[i] = 1;
      int l, r;
      scanf("%d%d", &l, &r);
      E[i].push_back(l);
      E[i].push_back(r);
      fa[l] = i;
      fa[r] = i;
    } else if (s[0] == 'I') {
      leaf[p] = i;
      int x;
      scanf("%d", &x);
      type[i] = 2;
      va[i] = x;
      p++;
    } else if (s[0] == 'X') {
      type[i] = 3;
      int l, r;
      scanf("%d%d", &l, &r);
      E[i].push_back(l);
      E[i].push_back(r);
      fa[l] = i;
      fa[r] = i;
    } else if (s[0] == 'N') {
      type[i] = 4;
      int x;
      scanf("%d", &x);
      E[i].push_back(x);
      fa[x] = i;
    } else {
      type[i] = 5;
      int l, r;
      scanf("%d%d", &l, &r);
      E[i].push_back(l);
      E[i].push_back(r);
      fa[l] = i;
      fa[r] = i;
    }
  }
  dfs(1, -1);
  dfs2(1, 1);
  for (int i = 0; i < p; i++) {
    if (dp2[leaf[i]] == 1) {
      printf("%d", !dp[1]);
    } else {
      printf("%d", dp[1]);
    }
  }
}
