#include <bits/stdc++.h>
using namespace std;
struct Node {
  string oper;
  bool val;
  int left = -1;
  int right = -1;
  bool will_left_change = false;
  bool will_right_change = false;
};
vector<Node> tree;
bool f(bool l_val, bool r_val, string oper) {
  if (oper == "AND") {
    return (l_val && r_val);
  } else if (oper == "OR") {
    return (l_val || r_val);
  } else if (oper == "XOR") {
    return (l_val ^ r_val);
  }
}
void calc(Node &v) {
  if (v.oper == "IN") return;
  calc(tree[v.left]);
  if (v.right != -1) {
    calc(tree[v.right]);
  }
  if (v.right == -1)
    v.val = !tree[v.left].val;
  else {
    v.val = f(tree[v.left].val, tree[v.right].val, v.oper);
  }
  if (v.right == -1)
    v.will_left_change = true;
  else {
    v.will_left_change = (f(tree[v.left].val, tree[v.right].val, v.oper) !=
                          f(!tree[v.left].val, tree[v.right].val, v.oper));
    v.will_right_change = (f(tree[v.left].val, tree[v.right].val, v.oper) !=
                           f(tree[v.left].val, !tree[v.right].val, v.oper));
  }
}
vector<int> ans;
void calc_leaves(Node &v, int ones_cnt, int depth, int v_index) {
  if (v.oper == "IN") {
    if (ones_cnt == depth) {
      ans[v_index] = !tree[1].val;
    } else {
      ans[v_index] = tree[1].val;
    }
    return;
  }
  calc_leaves(tree[v.left], ones_cnt + (int)v.will_left_change, depth + 1,
              v.left);
  if (v.right != -1) {
    calc_leaves(tree[v.right], ones_cnt + (int)v.will_right_change, depth + 1,
                v.right);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  tree.resize(n + 1);
  ans.resize(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (s == "IN") {
      int z;
      cin >> z;
      tree[i].oper = s;
      tree[i].val = z;
    } else if (s == "NOT") {
      int id;
      cin >> id;
      tree[i].oper = s;
      tree[i].left = id;
    } else {
      int left, right;
      cin >> left >> right;
      tree[i].oper = s;
      tree[i].left = left;
      tree[i].right = right;
    }
  }
  calc(tree[1]);
  calc_leaves(tree[1], 0, 0, -1);
  for (int i = 1; i <= n; i++) {
    if (ans[i] != -1) cout << ans[i];
  }
  return 0;
}
