#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  if (f)
    for (; isdigit(c); c = getchar()) x = x * 10 - 48 + c;
  else
    for (; isdigit(c); c = getchar()) x = x * 10 + 48 - c;
}
template <typename T, typename... Args>
void read(T &t, Args &...args) {
  read(t), read(args...);
}
const int N = 1e6 + 5;
int n, ls[N], rs[N];
string op[N];
bool val[N], f[N];
void dfs1(int u) {
  if (op[u] == "AND") {
    dfs1(ls[u]), dfs1(rs[u]);
    val[u] = val[ls[u]] & val[rs[u]];
    f[ls[u]] = ((!val[ls[u]]) & val[rs[u]]) ^ val[u];
    f[rs[u]] = (val[ls[u]] & (!val[rs[u]])) ^ val[u];
  } else if (op[u] == "OR") {
    dfs1(ls[u]), dfs1(rs[u]);
    val[u] = val[ls[u]] | val[rs[u]];
    f[ls[u]] = ((!val[ls[u]]) | val[rs[u]]) ^ val[u];
    f[rs[u]] = (val[ls[u]] | (!val[rs[u]])) ^ val[u];
  } else if (op[u] == "XOR") {
    dfs1(ls[u]), dfs1(rs[u]);
    val[u] = val[ls[u]] ^ val[rs[u]];
    f[ls[u]] = ((!val[ls[u]]) ^ val[rs[u]]) ^ val[u];
    f[rs[u]] = (val[ls[u]] ^ (!val[rs[u]])) ^ val[u];
  } else if (op[u] == "NOT") {
    dfs1(ls[u]);
    val[u] = !val[ls[u]];
    f[ls[u]] = 1;
  }
}
void dfs2(int u) {
  if (ls[u]) {
    f[ls[u]] &= f[u], dfs2(ls[u]);
    if (rs[u]) f[rs[u]] &= f[u], dfs2(rs[u]);
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    cin >> op[i];
    if (op[i] == "AND" || op[i] == "OR" || op[i] == "XOR")
      read(ls[i], rs[i]);
    else if (op[i] == "NOT")
      read(ls[i]);
    else {
      int x;
      read(x);
      val[i] = x;
    }
  }
  dfs1(1), f[1] = 1, dfs2(1);
  for (int i = 1; i <= n; ++i)
    if (op[i] == "IN") putchar('0' + (val[1] ^ f[i]));
  return 0;
}
