#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long OO = 1LL << 62;
const int mod = 1e9 + 7;
int qpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = 1LL * ans * x % mod;
    x = 1LL * x * x % mod;
    y >>= 1;
  }
  return ans;
}
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
namespace io {
const int L = (1 << 21) + 1;
char ibuf[L], *iS, *iT, obuf[L], *oS = obuf, *oT = obuf + L - 1, c, st[55];
int f, tp;
inline char getc() {
  return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
}
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putc(st[tp--]);
}
inline void gs(char *s, int &l) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 'a' || c > 'z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  for (l = 0; c <= 'z' && c >= 'a';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    s[l++] = c;
  s[l] = 0;
}
inline void ps(const char *s) {
  for (int i = 0, n = strlen(s); i < n; i++) putc(s[i]);
}
struct IOFLUSHER {
  ~IOFLUSHER() { flush(); }
} _ioflusher_;
};  // namespace io
using io::getc;
using io::gi;
using io::gs;
using io::print;
using io::ps;
using io::putc;
const int N = 1e6 + 100;
int w[N];
char o[N];
int son1[N], son2[N];
int ans[N];
int f[N];
void init(int k) {
  if (!o[k])
    f[k] = w[k];
  else {
    if (son1[k]) init(son1[k]);
    if (son2[k]) init(son2[k]);
    if (o[k] == 'N')
      f[k] = !f[son1[k]];
    else if (o[k] == 'A')
      f[k] = f[son1[k]] & f[son2[k]];
    else if (o[k] == 'O')
      f[k] = f[son1[k]] | f[son2[k]];
    else
      f[k] = f[son1[k]] ^ f[son2[k]];
  }
}
void dfs(int k, int s0, int s1) {
  if (!o[k])
    ans[k] = w[k] ? s0 : s1;
  else {
    if (o[k] == 'N')
      dfs(son1[k], s1, s0);
    else if (o[k] == 'A') {
      if (f[son2[k]])
        dfs(son1[k], s0, s1);
      else
        dfs(son1[k], s0, s0);
      if (f[son1[k]])
        dfs(son2[k], s0, s1);
      else
        dfs(son2[k], s0, s0);
    } else if (o[k] == 'O') {
      if (f[son2[k]])
        dfs(son1[k], s1, s1);
      else
        dfs(son1[k], s0, s1);
      if (f[son1[k]])
        dfs(son2[k], s1, s1);
      else
        dfs(son2[k], s0, s1);
    } else if (o[k] == 'X') {
      if (f[son2[k]])
        dfs(son1[k], s1, s0);
      else
        dfs(son1[k], s0, s1);
      if (f[son1[k]])
        dfs(son2[k], s1, s0);
      else
        dfs(son2[k], s0, s1);
    }
  }
}
int main() {
  int n, i;
  gi(n);
  char c;
  for (i = 1; i <= n; i++) {
    while ((c = getc()) != 'A' && c != 'O' && c != 'X' && c != 'N' && c != 'I')
      ;
    if (c == 'I')
      gi(w[i]);
    else {
      o[i] = c;
      gi(son1[i]);
      if (c != 'N') gi(son2[i]);
    }
  }
  init(1);
  dfs(1, 0, 1);
  for (i = 1; i <= n; i++)
    if (!o[i]) print(ans[i]);
  return 0;
}
