#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::map;
using std::string;
int left[1000001];
int right[1000001];
int ttype[1000001];
bool val[1000001];
bool evaled[1000001];
int leaves[500001];
map<int, bool> flipped;
int countLeaves = 0;
bool eval(int i) {
  bool ll, rr;
  switch (ttype[i]) {
    case 0:
      return val[i];
    case 1:
      if (evaled[left[i]])
        ll = val[left[i]];
      else
        ll = eval(left[i]);
      if (evaled[right[i]])
        rr = val[right[i]];
      else
        rr = eval(right[i]);
      val[i] = ll & rr;
      evaled[i] = true;
      return val[i];
    case 2:
      if (evaled[left[i]])
        ll = val[left[i]];
      else
        ll = eval(left[i]);
      if (evaled[right[i]])
        rr = val[right[i]];
      else
        rr = eval(right[i]);
      val[i] = ll ^ rr;
      evaled[i] = true;
      return val[i];
    case 3:
      if (evaled[left[i]])
        ll = val[left[i]];
      else
        ll = eval(left[i]);
      if (evaled[right[i]])
        rr = val[right[i]];
      else
        rr = eval(right[i]);
      val[i] = ll | rr;
      evaled[i] = true;
      return val[i];
    case 4:
      if (evaled[left[i]])
        ll = val[left[i]];
      else
        ll = eval(left[i]);
      val[i] = !ll;
      evaled[i] = true;
      return val[i];
    default:
      return false;
  }
}
void flip(int i) {
  if (ttype[i] == 0)
    flipped[i] = true;
  else if (ttype[i] == 1) {
    if (val[i]) {
      flip(left[i]);
      flip(right[i]);
    } else {
      if (val[left[i]])
        flip(right[i]);
      else if (val[right[i]])
        flip(left[i]);
    }
  } else if (ttype[i] == 2) {
    flip(left[i]);
    flip(right[i]);
  } else if (ttype[i] == 3) {
    if (val[i]) {
      if (val[left[i]] && !val[right[i]])
        flip(left[i]);
      else if (!val[left[i]] && val[right[i]])
        flip(right[i]);
    } else {
      flip(left[i]);
      flip(right[i]);
    }
  } else if (ttype[i] == 4) {
    flip(left[i]);
  }
}
int main() {
  int N;
  cin >> N;
  string st;
  int l, r;
  for (int i = 1; i <= N; i++) {
    evaled[i] = false;
    cin >> st;
    if (st[0] == 'A') {
      cin >> l >> r;
      ttype[i] = 1;
      left[i] = l;
      right[i] = r;
    } else if (st[0] == 'I') {
      cin >> l;
      ttype[i] = 0;
      val[i] = (l == 1);
      evaled[i] = true;
      leaves[countLeaves] = i;
      flipped[i] = false;
      countLeaves = countLeaves + 1;
    } else if (st[0] == 'X') {
      cin >> l >> r;
      ttype[i] = 2;
      left[i] = l;
      right[i] = r;
    } else if (st[0] == 'O') {
      cin >> l >> r;
      ttype[i] = 3;
      left[i] = l;
      right[i] = r;
    } else {
      cin >> l;
      ttype[i] = 4;
      left[i] = l;
    }
  }
  eval(1);
  flip(1);
  bool v = val[1];
  for (auto x : flipped) {
    if (x.second)
      cout << !v;
    else
      cout << v;
  }
  return 0;
}
