#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int n;
int son[maxn + 5][2], fa[maxn + 5], flag[maxn + 5];
int dp[maxn + 5][2];
int type[maxn + 5], val[maxn + 5];
bool dfs(int x) {
  if (type[x] == 0) return val[x];
  if (type[x] == 4) return val[x] = (!dfs(son[x][0]));
  bool a = dfs(son[x][0]), b = dfs(son[x][1]);
  if (type[x] == 1) return val[x] = a && b;
  if (type[x] == 2) return val[x] = a || b;
  return val[x] = a ^ b;
}
int m = 0;
pair<int, int> ans[maxn + 5];
void dfs2(int x) {
  if (x == 1) {
    dp[1][0] = 0, dp[1][1] = 1;
  } else {
    int p = fa[x];
    if (type[p] == 4) {
      dp[x][0] = dp[p][1];
      dp[x][1] = dp[p][0];
    } else {
      int y = son[p][flag[x] ^ 1];
      int z0 = 0, z1 = 0;
      if (type[p] == 1)
        z0 = 0 && val[y], z1 = 1 && val[y];
      else if (type[p] == 2)
        z0 = 0 || val[y], z1 = 1 || val[y];
      else
        z0 = 0 ^ val[y], z1 = 1 ^ val[y];
      dp[x][0] = dp[p][z0], dp[x][1] = dp[p][z1];
    }
  }
  if (type[x] == 0) {
    ans[++m] = make_pair(x, dp[x][val[x] ^ 1]);
  } else if (type[x] == 4) {
    dfs2(son[x][0]);
  } else {
    dfs2(son[x][0]);
    dfs2(son[x][1]);
  }
}
int main() {
  scanf("%d", &n);
  char ord[10];
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%s", ord);
    if (ord[0] == 'I') {
      scanf("%d", &x);
      type[i] = 0;
      val[i] = x;
    } else if (ord[0] == 'N') {
      scanf("%d", &x);
      type[i] = 4;
      son[i][0] = x;
      fa[x] = i;
      flag[x] = 0;
    } else {
      scanf("%d%d", &x, &y);
      son[i][0] = x, son[i][1] = y;
      fa[x] = i, fa[y] = i;
      flag[x] = 0, flag[y] = 1;
      if (ord[0] == 'A')
        type[i] = 1;
      else if (ord[0] == 'O')
        type[i] = 2;
      else
        type[i] = 3;
    }
  }
  dfs(1);
  dfs2(1);
  sort(ans + 1, ans + 1 + m);
  for (int i = 1; i <= m; ++i) printf("%d", ans[i].second);
  puts("");
  return 0;
}
