#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y, id;
  char str[15];
} Point;
Point s[1000005];
int ans[1000005], flag[1000005];
int Sech(int u) {
  int i, p1, p2;
  if (s[u].str[1] == 'I') return s[u].x;
  if (s[u].str[1] == 'N') return Sech(s[u].x) ^ 1;
  if (s[u].str[1] == 'X') return Sech(s[u].x) ^ Sech(s[u].y);
  if (s[u].str[1] == 'A') {
    p1 = Sech(s[u].x), p2 = Sech(s[u].y);
    if (p1 == 0) flag[s[u].y] = 1;
    if (p2 == 0) flag[s[u].x] = 1;
    return p1 & p2;
  }
  if (s[u].str[1] == 'O') {
    p1 = Sech(s[u].x), p2 = Sech(s[u].y);
    if (p1 == 1) flag[s[u].y] = 1;
    if (p2 == 1) flag[s[u].x] = 1;
    return p1 | p2;
  }
  printf("WA\n");
  return -1;
}
void Sech2(int u) {
  int i, p1, p2;
  if (flag[u]) return;
  if (s[u].str[1] == 'I') ans[s[u].id] = 1;
  if (s[u].str[1] == 'N') Sech2(s[u].x);
  if (s[u].str[1] == 'X' || s[u].str[1] == 'A' || s[u].str[1] == 'O') {
    Sech2(s[u].x);
    Sech2(s[u].y);
  }
}
int main(void) {
  int n, i, now;
  scanf("%d", &n);
  memset(ans, -1, sizeof(ans));
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i].str + 1);
    if (s[i].str[1] == 'I' || s[i].str[1] == 'N')
      scanf("%d", &s[i].x);
    else
      scanf("%d%d", &s[i].x, &s[i].y);
    s[i].id = i;
    if (s[i].str[1] == 'I') ans[i] = 0;
  }
  now = Sech(1);
  Sech2(1);
  for (i = 1; i <= n; i++) {
    if (ans[i] == -1) continue;
    printf("%d", now ^ ans[i]);
  }
  puts("");
  return 0;
}
