#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int ch[N][2];
char t[N];
bool val[N];
bool calc(int u = 1) {
  bool v1 = -1, v2 = -1, res;
  if (ch[u][0]) v1 = calc(ch[u][0]);
  if (ch[u][1]) v2 = calc(ch[u][1]);
  switch (t[u]) {
    case 'I':
      res = val[u];
      break;
    case 'N':
      res = !v1;
      break;
    case 'A':
      res = v1 & v2;
      break;
    case 'X':
      res = v1 ^ v2;
      break;
    case 'O':
      res = v1 | v2;
      break;
  }
  return val[u] = res;
}
bool changes[N];
void dfs(int u = 1, bool c = true) {
  changes[u] = c;
  if (!c) {
    if (ch[u][0]) dfs(ch[u][0], c);
    if (ch[u][1]) dfs(ch[u][1], c);
    return;
  }
  switch (t[u]) {
    case 'N':
      dfs(ch[u][0]);
      break;
    case 'O':
      if (((val[ch[u][0]] ^ 1) | val[ch[u][1]]) == val[u])
        dfs(ch[u][0], false);
      else
        dfs(ch[u][0], true);
      if (((val[ch[u][1]] ^ 1) | val[ch[u][0]]) == val[u])
        dfs(ch[u][1], false);
      else
        dfs(ch[u][1], true);
      break;
    case 'A':
      if (((val[ch[u][0]] ^ 1) & val[ch[u][1]]) == val[u])
        dfs(ch[u][0], false);
      else
        dfs(ch[u][0], true);
      if (((val[ch[u][1]] ^ 1) & val[ch[u][0]]) == val[u])
        dfs(ch[u][1], false);
      else
        dfs(ch[u][1], true);
      break;
    case 'X':
      if (((val[ch[u][0]] ^ 1) ^ val[ch[u][1]]) == val[u])
        dfs(ch[u][0], false);
      else
        dfs(ch[u][0], true);
      if (((val[ch[u][1]] ^ 1) ^ val[ch[u][0]]) == val[u])
        dfs(ch[u][1], false);
      else
        dfs(ch[u][1], true);
      break;
  }
}
int main() {
  char str[4];
  int x;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s%d", str, &x);
    t[i] = str[0];
    if (t[i] == 'I')
      val[i] = x;
    else {
      ch[i][0] = x;
      if (t[i] != 'N') {
        cin >> x;
        ch[i][1] = x;
      }
    }
  }
  int val = calc();
  changes[1] = true;
  dfs();
  for (int i = 1; i <= n; ++i)
    if (t[i] == 'I') {
      if (changes[i])
        printf("%d", val ^ 1);
      else
        printf("%d", val);
    }
  printf("\n");
  return 0;
}
