#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, ans[N], vis[N], leave[N], cnt;
struct node {
  int ls, rs, val;
} T[N];
int dfs(int x) {
  int lson = T[x].ls, rson = T[x].rs;
  if (T[x].val >= 0) return ans[x] = T[x].val;
  if (T[x].val == -1) return ans[x] = dfs(lson) ^ dfs(rson);
  if (T[x].val == -2) return ans[x] = dfs(lson) & dfs(rson);
  if (T[x].val == -3) return ans[x] = dfs(lson) | dfs(rson);
  if (T[x].val == -4) return ans[x] = dfs(lson) ^ 1;
  return puts("ylsakioi");
}
void Dfs(int x) {
  int lson = T[x].ls, rson = T[x].rs;
  if (T[x].val >= 0) vis[x] = 1;
  if (T[x].val == -1) Dfs(lson), Dfs(rson);
  if (T[x].val == -2) {
    if (ans[lson] & ans[rson])
      Dfs(lson), Dfs(rson);
    else if (ans[lson] | ans[rson])
      Dfs(ans[lson] ? rson : lson);
  }
  if (T[x].val == -3) {
    if (ans[lson] & ans[rson]) return;
    if (ans[lson] | ans[rson])
      Dfs(ans[lson] ? lson : rson);
    else
      Dfs(lson), Dfs(rson);
  }
  if (T[x].val == -4) Dfs(lson);
}
int main() {
  char s[10];
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    if (s[0] == 'I')
      scanf("%d", &T[i].val), leave[++cnt] = i;
    else {
      if (s[0] == 'X') T[i].val = -1;
      if (s[0] == 'A') T[i].val = -2;
      if (s[0] == 'O') T[i].val = -3;
      if (s[0] == 'N') T[i].val = -4;
      scanf("%d", &T[i].ls);
      if (s[0] != 'N') scanf("%d", &T[i].rs);
    }
  }
  dfs(1);
  Dfs(1);
  for (int i = 1; i <= cnt; ++i) putchar(48 + (vis[leave[i]] ^ ans[1]));
  return 0;
}
