#include <bits/stdc++.h>
using namespace std;
inline void splay(int &v) {
  v = 0;
  char c = 0;
  int p = 1;
  while (c < '0' || c > '9') {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = (v << 3) + (v << 1) + c - '0';
    c = getchar();
  }
  v *= p;
}
const int N = 1000010;
int id[N], is[N], ls[N], rs[N], n, v[N], ans[N];
char s[N];
void dfs(int x) {
  if (id[x] == 1 || id[x] == 2 || id[x] == 5) {
    dfs(ls[x]), dfs(rs[x]);
    if (id[x] == 1) v[x] = v[ls[x]] & v[rs[x]];
    if (id[x] == 2) v[x] = v[ls[x]] | v[rs[x]];
    if (id[x] == 5) v[x] = v[ls[x]] ^ v[rs[x]];
  } else if (id[x] == 3) {
    dfs(ls[x]);
    v[x] = !v[ls[x]];
  }
}
void calc(int x, int is) {
  if (id[x] == 1) {
    if (v[ls[x]] > v[rs[x]]) swap(ls[x], rs[x]);
    if (v[rs[x]] == 0) {
      calc(ls[x], 0);
      calc(rs[x], 0);
    } else if (v[ls[x]] == 0 && v[rs[x]] == 1) {
      calc(ls[x], is);
      calc(rs[x], 0);
    } else {
      calc(ls[x], is);
      calc(rs[x], is);
    }
  } else if (id[x] == 2) {
    if (v[ls[x]] > v[rs[x]]) swap(ls[x], rs[x]);
    if (v[rs[x]] == 0) {
      calc(ls[x], is);
      calc(rs[x], is);
    } else if (v[ls[x]] == 0 && v[rs[x]] == 1) {
      calc(ls[x], 0);
      calc(rs[x], is);
    } else {
      calc(ls[x], 0);
      calc(rs[x], 0);
    }
  } else if (id[x] == 3 || id[x] == 5) {
    calc(ls[x], is);
    if (id[x] == 5) calc(rs[x], is);
  } else {
    if (is == 1)
      ans[x] = v[1] ^ 1;
    else
      ans[x] = v[1];
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    if (s[1] == 'A') {
      splay(ls[i]);
      splay(rs[i]);
      id[i] = 1;
    }
    if (s[1] == 'O') {
      splay(ls[i]);
      splay(rs[i]);
      id[i] = 2;
    }
    if (s[1] == 'N') {
      splay(ls[i]);
      id[i] = 3;
    }
    if (s[1] == 'I') {
      splay(v[i]);
      id[i] = 4;
    }
    if (s[1] == 'X') {
      splay(ls[i]);
      splay(rs[i]);
      id[i] = 5;
    }
  }
  dfs(1);
  calc(1, 1);
  for (int i = 1; i <= n; i++) {
    if (id[i] == 4) {
      printf("%d", ans[i]);
    }
  }
}
