#include <bits/stdc++.h>
using namespace std;
int n;
int fa[1000005];
int son[1000005][2];
int r[1000005];
bool v[1000005];
int dp[1000005];
char s[10];
queue<int> q;
bool dfs(int p) {
  if (r[p] == 0) return v[p];
  if (r[p] == 1) {
    dfs(son[p][0]);
    dfs(son[p][1]);
    return v[p] = v[son[p][0]] && v[son[p][1]];
  }
  if (r[p] == 2) {
    dfs(son[p][0]);
    dfs(son[p][1]);
    return v[p] = v[son[p][0]] || v[son[p][1]];
  }
  if (r[p] == 3) {
    if (dfs(son[p][0]) == dfs(son[p][1]))
      return v[p] = 0;
    else
      return v[p] = 1;
  }
  if (r[p] == 4) return v[p] = !dfs(son[p][0]);
}
bool solve(int p) {
  if (dp[p] != -1) return dp[p];
  if (p == 1) return true;
  int ff = fa[p];
  if (r[ff] == 1) {
    int br = son[ff][0] + son[ff][1] - p;
    if (v[br]) return dp[p] = solve(ff);
    return false;
  } else if (r[ff] == 2) {
    int br = son[ff][0] + son[ff][1] - p;
    if (!v[br]) return dp[p] = solve(ff);
    return false;
  } else if (r[ff] == 3) {
    return dp[p] = solve(ff);
  } else if (r[ff] == 4) {
    return dp[p] = solve(ff);
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    dp[i] = -1;
    int x, y;
    scanf("%s", s);
    if (s[0] == 'I') {
      r[i] = 0;
      scanf("%d", &x);
      v[i] = x;
      q.push(i);
    } else if (s[0] == 'A') {
      r[i] = 1;
      scanf("%d%d", &x, &y);
      fa[x] = fa[y] = i;
      son[i][0] = x;
      son[i][1] = y;
    } else if (s[0] == 'O') {
      r[i] = 2;
      scanf("%d%d", &x, &y);
      fa[x] = fa[y] = i;
      son[i][0] = x;
      son[i][1] = y;
    } else if (s[0] == 'X') {
      r[i] = 3;
      scanf("%d%d", &x, &y);
      fa[x] = fa[y] = i;
      son[i][0] = x;
      son[i][1] = y;
    } else if (s[0] == 'N') {
      r[i] = 4;
      scanf("%d", &x);
      fa[x] = i;
      son[i][0] = x;
    }
  }
  dfs(1);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (!solve(t))
      printf("%d", v[1]);
    else
      printf("%d", !v[1]);
  }
  printf("\n");
  return 0;
}
