#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, ans, now, chk[N];
char s[10];
struct node {
  int ls, rs, op;
  bool v;
} a[N];
bool dfs(int x) {
  if (!a[x].op) return a[x].v;
  bool lv = dfs(a[x].ls), rv, res;
  if (a[x].op != 4) rv = dfs(a[x].rs);
  if (a[x].op == 1)
    res = (lv & rv);
  else if (a[x].op == 2)
    res = (lv | rv);
  else if (a[x].op == 3)
    res = (lv ^ rv);
  else
    res = lv ^ 1;
  return a[x].v = res;
}
void check(int x, int ok) {
  if (!a[x].op) {
    chk[x] = ok;
    return;
  }
  if (ok) {
    chk[x] = ok;
    check(a[x].ls, ok);
    if (a[x].op != 4) check(a[x].rs, ok);
    return;
  }
  int ltmp = 0, rtmp = 0;
  chk[x] = ok;
  if (a[x].op == 1) {
    if (a[a[x].ls].v == 0) rtmp = 1;
    if (a[x].op != 4 && a[a[x].rs].v == 0) ltmp = 1;
  } else if (a[x].op == 2) {
    if (a[a[x].ls].v == 1) rtmp = 1;
    if (a[x].op != 4 && a[a[x].rs].v == 1) ltmp = 1;
  }
  check(a[x].ls, ltmp);
  if (a[x].op != 4) check(a[x].rs, rtmp);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1, u, v; i <= n; i++) {
    cin >> s;
    if (s[0] == 'I') {
      cin >> v;
      a[i].v = v;
    } else if (s[0] == 'A') {
      cin >> u >> v;
      a[i].ls = u, a[i].rs = v;
      a[i].op = 1;
    } else if (s[0] == 'O') {
      cin >> u >> v;
      a[i].ls = u, a[i].rs = v;
      a[i].op = 2;
    } else if (s[0] == 'X') {
      cin >> u >> v;
      a[i].ls = u, a[i].rs = v;
      a[i].op = 3;
    } else {
      cin >> u;
      a[i].ls = u;
      a[i].op = 4;
    }
  }
  ans = dfs(1);
  check(1, 0);
  for (int i = 1; i <= n; i++)
    if (!a[i].op) {
      if (chk[i])
        cout << ans;
      else
        cout << 1 - ans;
    }
  return 0;
}
