#include <bits/stdc++.h>
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
vector<int> g[1000010];
int w[1000010], dp[1000010];
int cal(int op, int a, int b = 0) {
  if (op == -1)
    return !a;
  else if (op == -2)
    return a & b;
  else if (op == -3)
    return a | b;
  return a ^ b;
}
void dfs(int u) {
  if (w[u] >= 0) {
    dp[u] = w[u];
    return;
  }
  vector<int> val;
  for (auto &v : g[u]) {
    dfs(v);
    val.push_back(dp[v]);
  }
  if (w[u] == -1)
    dp[u] = !val[0];
  else
    dp[u] = cal(w[u], val[0], val[1]);
}
int D, f[1000010][2];
void go(int u, int s) {
  if (s == 0) return;
  if (w[u] >= 0) {
    if (s >> (!w[u]) & 1) {
      f[u][D] = 1;
    }
    return;
  }
  if (w[u] == -1) {
    int ss = 0;
    if (s >> 0 & 1) ss |= 2;
    if (s >> 1 & 1) ss |= 1;
    go(g[u][0], ss);
  } else {
    int first = g[u][0], second = g[u][1];
    int s1 = 0, s2 = 0;
    if (w[u] == -2) {
      if (s >> 0 & 1) {
        s1 = s2 = 1;
        if (dp[second] == 0) s1 |= 2;
        if (dp[first] == 0) s2 |= 2;
      }
      if (s >> 1 & 1) {
        if (dp[second] == 1) s1 |= 2;
        if (dp[first] == 1) s2 |= 2;
      }
    } else if (w[u] == -3) {
      if (s >> 0 & 1) {
        if (dp[second] == 0) s1 |= 1;
        if (dp[first] == 0) s2 |= 1;
      }
      if (s >> 1 & 1) {
        s1 |= 2, s2 |= 2;
        if (dp[second] == 1) s1 |= 1;
        if (dp[first] == 1) s2 |= 1;
      }
    } else {
      if (s >> 0 & 1) {
        if (dp[second] == 0)
          s1 |= 1;
        else
          s1 |= 2;
        if (dp[first] == 0)
          s2 |= 1;
        else
          s2 |= 2;
      }
      if (s >> 1 & 1) {
        if (dp[second] == 1)
          s1 |= 1;
        else
          s1 |= 2;
        if (dp[first] == 1)
          s2 |= 1;
        else
          s2 |= 2;
      }
    }
    go(first, s1);
    go(second, s2);
  }
}
int main() {
  srand(time(NULL));
  int T, ca = 0, m = 0, k, i, j, n, K;
  scanf("%d", &n);
  char s[10];
  for (int i = 1; i < n + 1; i++) {
    scanf("%s%d", s, &j);
    if (s[0] == 'I') {
      w[i] = j;
    } else if (s[0] == 'N') {
      w[i] = -1;
      g[i].push_back(j);
    } else {
      scanf("%d", &k);
      g[i].push_back(j), g[i].push_back(k);
      if (s[0] == 'A')
        w[i] = -2;
      else if (s[0] == 'O')
        w[i] = -3;
      else
        w[i] = -4;
    }
  }
  dfs(1);
  D = 1;
  go(1, 2);
  D = 0;
  go(1, 1);
  for (int i = 1; i < n + 1; i++)
    if (w[i] >= 0) {
      if (f[i][0])
        printf("0");
      else
        printf("1");
    }
  puts("");
}
