#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
  char s[20];
};
node tree[1000000 + 10];
int n;
int ans[1000000 + 10];
int tag[1000000 + 10];
int getans(int u) {
  if (tree[u].s[0] == 'I') return tree[u].l;
  if (tree[u].s[0] == 'N') return 1 ^ getans(tree[u].l);
  if (tree[u].s[0] == 'A') {
    int v1 = getans(tree[u].l);
    int v2 = getans(tree[u].r);
    if (v1 == 0) tag[tree[u].r] = 1;
    if (v2 == 0) tag[tree[u].l] = 1;
    return v1 & v2;
  }
  if (tree[u].s[0] == 'O') {
    int v1 = getans(tree[u].l);
    int v2 = getans(tree[u].r);
    if (v1 == 1) tag[tree[u].r] = 1;
    if (v2 == 1) tag[tree[u].l] = 1;
    return v1 | v2;
  }
  if (tree[u].s[0] == 'X') {
    int v1 = getans(tree[u].l);
    int v2 = getans(tree[u].r);
    return v1 ^ v2;
  }
}
void dfs(int u) {
  if (tag[u]) return;
  if (tree[u].s[0] == 'I') {
    ans[u] = 1;
    return;
  }
  if (tree[u].s[0] == 'N')
    dfs(tree[u].l);
  else {
    dfs(tree[u].l);
    dfs(tree[u].r);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", tree[i].s);
    if (tree[i].s[0] == 'I' || tree[i].s[0] == 'N') {
      scanf("%d", &tree[i].l);
    } else {
      scanf("%d%d", &tree[i].l, &tree[i].r);
    }
    if (tree[i].s[0] == 'I')
      ans[i] = 0;
    else
      ans[i] = -1;
  }
  int pre = getans(1);
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) continue;
    cout << (pre ^ ans[i]);
  }
  cout << endl;
}
