#include <bits/stdc++.h>
using namespace std;
using node = tuple<string, long, long>;
vector<node> a;
vector<bool> val;
vector<bool> impacts;
bool is_input(const string& node_type) { return node_type == "IN"; }
bool is_unary(const string& node_type) {
  return node_type == "IN" || node_type == "NOT";
}
bool calculate(long i) {
  string node_type = get<0>(a[i]);
  long left = get<1>(a[i]);
  long right = get<2>(a[i]);
  bool result;
  if (node_type == "IN") {
    result = (left == 1);
  } else if (node_type == "NOT") {
    result = !calculate(left);
  } else if (node_type == "AND") {
    bool left_val = calculate(left);
    bool right_val = calculate(right);
    result = (left_val && right_val);
  } else if (node_type == "OR") {
    bool left_val = calculate(left);
    bool right_val = calculate(right);
    result = (left_val || right_val);
  } else if (node_type == "XOR") {
    bool left_val = calculate(left);
    bool right_val = calculate(right);
    result = (left_val != right_val);
  }
  val[i] = result;
  return result;
}
void calculate_impact(long i, bool branch_impact) {
  if (!branch_impact) {
    return;
  }
  string node_type = get<0>(a[i]);
  long left = get<1>(a[i]);
  long right = get<2>(a[i]);
  impacts[i] = true;
  if (node_type == "IN") {
  } else if (node_type == "NOT") {
    calculate_impact(left, true);
  } else if (node_type == "AND") {
    calculate_impact(left, val[right]);
    calculate_impact(right, val[left]);
  } else if (node_type == "OR") {
    calculate_impact(left, !val[right]);
    calculate_impact(right, !val[left]);
  } else if (node_type == "XOR") {
    calculate_impact(left, true);
    calculate_impact(right, true);
  }
}
int main() {
  long n;
  cin >> n;
  a.reserve(n);
  for (int i = 0; i < n; ++i) {
    string node_type;
    long left, right;
    cin >> node_type;
    if (is_unary(node_type)) {
      cin >> left;
      if (!is_input(node_type)) {
        --left;
      }
      right = -1;
    } else {
      cin >> left >> right;
      --left;
      --right;
    }
    a.push_back(make_tuple(node_type, left, right));
  }
  val.resize(n);
  calculate(0);
  impacts.resize(n);
  fill(impacts.begin(), impacts.end(), false);
  calculate_impact(0, true);
  for (int i = 0; i < n; ++i) {
    if (is_input(get<0>(a[i]))) {
      bool result = impacts[i] ? (!val[0]) : (val[0]);
      cout << (result ? '1' : '0');
    }
  }
  cout << '\n';
}
