#include <bits/stdc++.h>
using namespace std;
int N;
const int maxn = 1e6 + 10;
struct Node {
  int opt;
  int val;
  int l, r;
  int lst;
} node[maxn];
int IN[maxn];
int cnt;
string ss;
set<int> change;
void read() {
  cin >> N;
  int l, r, lst;
  for (int i = 1; i <= N; i++) {
    cin >> ss;
    switch (ss[0]) {
      case 'A':
        scanf("%d%d", &l, &r);
        node[i].opt = 1;
        node[i].l = l;
        node[i].r = r;
        node[l].lst = i;
        node[r].lst = i;
        break;
      case 'I':
        scanf("%d", &l);
        node[i].opt = 2;
        node[i].val = l;
        IN[cnt] = i;
        cnt++;
        break;
      case 'X':
        scanf("%d%d", &l, &r);
        node[i].opt = 3;
        node[i].l = l;
        node[i].r = r;
        node[l].lst = i;
        node[r].lst = i;
        break;
      case 'N':
        scanf("%d", &l);
        node[i].opt = 4;
        node[l].lst = i;
        node[i].l = l;
        break;
      case 'O':
        scanf("%d%d", &l, &r);
        node[i].opt = 5;
        node[i].l = l;
        node[i].r = r;
        node[l].lst = i;
        node[r].lst = i;
    }
  }
}
void getval(int id) {
  switch (node[id].opt) {
    case 1:
      getval(node[id].l);
      getval(node[id].r);
      node[id].val = node[node[id].l].val & node[node[id].r].val;
      break;
    case 2:
      break;
    case 3:
      getval(node[id].l);
      getval(node[id].r);
      node[id].val = node[node[id].l].val ^ node[node[id].r].val;
      break;
    case 4:
      getval(node[id].l);
      node[id].val = (!node[node[id].l].val);
      break;
    case 5:
      getval(node[id].l);
      getval(node[id].r);
      node[id].val = node[node[id].l].val | node[node[id].r].val;
      break;
  }
  return;
}
void renew(int id) {
  switch (node[id].opt) {
    case 1:
      if (node[node[id].l].val == 1 && node[node[id].r].val == 1) {
        renew(node[id].l);
        renew(node[id].r);
      }
      if (node[node[id].l].val == 1 && node[node[id].r].val == 0) {
        renew(node[id].r);
      }
      if (node[node[id].l].val == 0 && node[node[id].r].val == 1) {
        renew(node[id].l);
      }
      break;
    case 2:
      change.insert(id);
      break;
    case 3:
      renew(node[id].l);
      renew(node[id].r);
      break;
    case 4:
      renew(node[id].l);
      break;
    case 5:
      if (node[node[id].l].val == 0 && node[node[id].r].val == 0) {
        renew(node[id].l);
        renew(node[id].r);
      }
      if (node[node[id].l].val == 1 && node[node[id].r].val == 0) {
        renew(node[id].l);
      }
      if (node[node[id].l].val == 0 && node[node[id].r].val == 1) {
        renew(node[id].r);
      }
      break;
  }
  return;
}
int main() {
  read();
  getval(1);
  renew(1);
  int ans = node[1].val;
  for (int i = 0; i < cnt; i++) {
    if (change.find(IN[i]) != change.end()) {
      printf("%d", !ans);
    } else {
      printf("%d", ans);
    }
  }
  return 0;
}
