#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline void upd1(T1& a, const T2& b) {
  if (a > b) a = b;
}
template <class T1, class T2>
inline void upd2(T1& a, const T2& b) {
  if (a < b) a = b;
}
template <class T>
inline bool equ(const T& a, const T& b) {
  return !memcmp(&a, &b, sizeof a);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
struct ano {
  operator long long() {
    long long x = 0, y = 0, c = getchar();
    while (c < 48) y = c == 45, c = getchar();
    while (c > 47) x = x * 10 + c - 48, c = getchar();
    return y ? -x : x;
  }
} buf;
const int N = 1e6 + 5;
char t[N][4];
int w[N], c[N][2], f[N][2];
void dfs1(int u) {
  if (int i = c[u][0]) {
    dfs1(i);
    if (*t[u] == 'N') w[u] = w[i] ^ 1;
    if (int j = c[u][1]) {
      dfs1(j);
      if (*t[u] == 'A') w[u] = w[i] & w[j];
      if (*t[u] == 'O') w[u] = w[i] | w[j];
      if (*t[u] == 'X') w[u] = w[i] ^ w[j];
    }
  }
}
void dfs2(int u) {
  if (int i = c[u][0]) {
    if (*t[u] == 'N') {
      f[i][0] = f[u][1];
      f[i][1] = f[u][0];
    }
    if (int j = c[u][1]) {
      if (*t[u] == 'A') {
        f[i][0] = f[u][0 & w[j]];
        f[i][1] = f[u][1 & w[j]];
        f[j][0] = f[u][0 & w[i]];
        f[j][1] = f[u][1 & w[i]];
      }
      if (*t[u] == 'O') {
        f[i][0] = f[u][0 | w[j]];
        f[i][1] = f[u][1 | w[j]];
        f[j][0] = f[u][0 | w[i]];
        f[j][1] = f[u][1 | w[i]];
      }
      if (*t[u] == 'X') {
        f[i][0] = f[u][0 ^ w[j]];
        f[i][1] = f[u][1 ^ w[j]];
        f[j][0] = f[u][0 ^ w[i]];
        f[j][1] = f[u][1 ^ w[i]];
      }
      dfs2(j);
    }
    dfs2(i);
  }
}
int main() {
  int n = buf;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", t[i]);
    if (*t[i] == 'I')
      scanf("%d", w + i);
    else {
      scanf("%d", c[i]);
      if (*t[i] != 'N') scanf("%d", c[i] + 1);
    }
  }
  dfs1(1);
  f[1][1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; ++i)
    if (!c[i][0]) printf("%d", f[i][w[i] ^ 1]);
}
