#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int f[N];
int son[N][2];
int a[N];
int ret[N];
int ans[N];
int n;
char s[101];
void dfs(int x) {
  if (f[x] <= 2 || f[x] == 5) {
    dfs(son[x][0]);
    dfs(son[x][1]);
    if (f[x] == 1)
      a[x] = a[son[x][0]] & a[son[x][1]];
    else if (f[x] == 2)
      a[x] = a[son[x][0]] | a[son[x][1]];
    else
      a[x] = a[son[x][0]] ^ a[son[x][1]];
  } else if (f[x] == 3) {
    dfs(son[x][0]);
    a[x] = a[son[x][0]] ^ 1;
  }
};
void work(int x, int t) {
  if (f[x] == 1) {
    if (a[son[x][0]] > a[son[x][1]]) swap(son[x][0], son[x][1]);
    if (!a[son[x][1]]) {
      work(son[x][0], 0);
      work(son[x][1], 0);
    } else if (!a[son[x][0]] && a[son[x][1]] == 1) {
      work(son[x][0], t);
      work(son[x][1], 0);
    } else
      for (int i(0); i <= (1); ++i) work(son[x][i], t);
  } else if (f[x] == 2) {
    if (a[son[x][0]] > a[son[x][1]]) swap(son[x][0], son[x][1]);
    if (!a[son[x][1]]) {
      work(son[x][0], t);
      work(son[x][1], t);
    } else if (!a[son[x][0]] && a[son[x][1]] == 1) {
      work(son[x][0], 0);
      work(son[x][1], t);
    } else
      for (int i(0); i <= (1); ++i) work(son[x][i], 0);
  } else if (f[x] == 3)
    work(son[x][0], t);
  else if (f[x] == 5)
    for (int i(0); i <= (1); ++i) work(son[x][i], t);
  else
    ans[x] = ((t == 1) ? (a[1] ^ 1) : a[1]);
};
int main() {
  scanf("%d", &n);
  for (int i(1); i <= (n); ++i) {
    scanf("%s", s);
    if (s[0] == 'A') {
      scanf("%d%d", &son[i][0], &son[i][1]);
      f[i] = 1;
      continue;
    } else if (s[0] == 'O') {
      scanf("%d%d", &son[i][0], &son[i][1]);
      f[i] = 2;
    } else if (s[0] == 'N') {
      scanf("%d", &son[i][0]);
      f[i] = 3;
    } else if (s[0] == 'I') {
      scanf("%d", a + i);
      f[i] = 4;
    } else {
      scanf("%d%d", &son[i][0], &son[i][1]);
      f[i] = 5;
    }
  }
  dfs(1);
  work(1, 1);
  for (int i(1); i <= (n); ++i)
    if (f[i] == 4) printf("%d", ans[i]);
  putchar(10);
}
