#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int f;
  char tp;
  int r;
  int fa;
  int s1, s2;
} l[1000010];
vector<int> v;
int dfs(int x) {
  if (l[x].tp == 'I') return l[x].r;
  if (l[x].tp == 'A') return l[x].r = dfs(l[x].s1) & dfs(l[x].s2);
  if (l[x].tp == 'O') return l[x].r = dfs(l[x].s1) | dfs(l[x].s2);
  if (l[x].tp == 'N') return l[x].r = !dfs(l[x].s1);
  return l[x].r = dfs(l[x].s1) ^ dfs(l[x].s2);
}
void chk(int x) {
  if (l[x].tp == 'A') {
    if (l[l[x].s1].r == 0 && l[l[x].s2].r == 0) return;
    if (l[l[x].s1].r == 0 && l[l[x].s2].r == 1) {
      l[l[x].s1].f = 1;
      chk(l[x].s1);
    }
    if (l[l[x].s1].r == 1 && l[l[x].s2].r == 0) {
      l[l[x].s2].f = 1;
      chk(l[x].s2);
    }
    if (l[l[x].s1].r == 1 && l[l[x].s2].r == 1) {
      l[l[x].s1].f = 1;
      chk(l[x].s1);
      l[l[x].s2].f = 1;
      chk(l[x].s2);
    }
  } else if (l[x].tp == 'O') {
    if (l[l[x].s1].r == 1 && l[l[x].s2].r == 1) return;
    if (l[l[x].s1].r == 1 && l[l[x].s2].r == 0) {
      l[l[x].s1].f = 1;
      chk(l[x].s1);
    }
    if (l[l[x].s1].r == 0 && l[l[x].s2].r == 1) {
      l[l[x].s2].f = 1;
      chk(l[x].s2);
    }
    if (l[l[x].s1].r == 0 && l[l[x].s2].r == 0) {
      l[l[x].s1].f = 1;
      chk(l[x].s1);
      l[l[x].s2].f = 1;
      chk(l[x].s2);
    }
  } else if (l[x].tp == 'N') {
    l[l[x].s1].f = 1;
    chk(l[x].s1);
  } else if (l[x].tp == 'I')
    return;
  else {
    l[l[x].s1].f = 1;
    chk(l[x].s1);
    l[l[x].s2].f = 1;
    chk(l[x].s2);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  char c[5];
  for (int i = 1; i <= n; i++) {
    cin >> c;
    l[i].tp = c[0];
    if (c[0] == 'I') {
      int a;
      cin >> a;
      l[i].r = a;
      v.push_back(i);
    } else if (c[0] == 'N') {
      int a;
      cin >> a;
      l[i].s1 = a;
      l[a].fa = i;
    } else {
      int a, b;
      cin >> a >> b;
      l[i].s1 = a;
      l[i].s2 = b;
      l[a].fa = i;
      l[b].fa = i;
    }
  }
  dfs(1);
  chk(1);
  for (auto i : v)
    if (!l[i].f)
      cout << l[1].r;
    else
      cout << (l[1].r ^ 1);
  cout << endl;
  return 0;
}
