#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int x[maxn + 5], y[maxn + 5], type[maxn + 5], ans[maxn + 5], res[maxn + 5];
int n, now;
char s[5];
void dfs(int k) {
  if (!type[k]) return;
  if (type[k] == 1) {
    dfs(x[k]), dfs(y[k]);
    ans[k] = ans[x[k]] & ans[y[k]];
  } else if (type[k] == 2) {
    dfs(x[k]), dfs(y[k]);
    ans[k] = ans[x[k]] | ans[y[k]];
  } else if (type[k] == 3) {
    dfs(x[k]), dfs(y[k]);
    ans[k] = ans[x[k]] ^ ans[y[k]];
  } else {
    dfs(x[k]);
    ans[k] = 1 - ans[x[k]];
  }
}
void dfs1(int k) {
  if (!type[k]) {
    res[k] = 1 - res[k];
    return;
  }
  if (type[k] == 1) {
    int a = ans[x[k]], b = ans[y[k]];
    if (a) dfs1(y[k]);
    if (b) dfs1(x[k]);
    return;
  }
  if (type[k] == 2) {
    int a = ans[x[k]], b = ans[y[k]];
    if (!a) dfs1(y[k]);
    if (!b) dfs1(x[k]);
    return;
  }
  if (type[k] == 3) {
    dfs1(x[k]), dfs1(y[k]);
    return;
  }
  if (type[k] == 4) {
    dfs1(x[k]);
    return;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    if (s[0] == 'I') {
      scanf("%d", &ans[i]);
      type[i] = 0;
    }
    if (s[0] == 'A') {
      scanf("%d%d", &x[i], &y[i]);
      type[i] = 1;
    }
    if (s[0] == 'O') {
      scanf("%d%d", &x[i], &y[i]);
      type[i] = 2;
    }
    if (s[0] == 'X') {
      scanf("%d%d", &x[i], &y[i]);
      type[i] = 3;
    }
    if (s[0] == 'N') {
      scanf("%d", &x[i]);
      type[i] = 4;
    }
  }
  dfs(1);
  now = ans[1];
  for (int i = 1; i <= n; ++i)
    if (!type[i]) res[i] = now;
  dfs1(1);
  for (int i = 1; i <= n; ++i)
    if (!type[i])
      if (res[i])
        printf("1");
      else
        printf("0");
  return 0;
}
