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