#include <bits/stdc++.h>
using ll = long long;
using namespace std;
enum op { AND, OR, XOR, NOT, IN };
struct vert {
  op bit_op;
  long long l, r, to;
  bool bit;
  bool val(vert a1, vert b1) {
    bool a = a1.bit, b = b1.bit;
    return val(a, b);
  }
  bool val(bool a, bool b) {
    if (bit_op == op::AND) {
      return a & b;
    }
    if (bit_op == op::OR) {
      return a | b;
    }
    if (bit_op == op::XOR) {
      return a ^ b;
    }
    if (bit_op == op::NOT) {
      return !a;
    }
    return bit;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  map<string, op> d = {{"AND", op::AND},
                       {"OR", op::OR},
                       {"XOR", op::XOR},
                       {"NOT", op::NOT},
                       {"IN", op::IN}};
  vector<vert> g(n + 1);
  string op_el;
  long long l, r;
  deque<long long> q;
  for (long long i = 1; i <= n; i++) {
    cin >> op_el >> l;
    g[i].bit_op = d[op_el];
    if (g[i].bit_op == op::IN) {
      q.push_back(i);
      g[i].bit = l;
    } else if (g[i].bit_op == op::NOT) {
      g[i].l = l;
      g[l].to = i;
    } else {
      cin >> r;
      g[i].l = l;
      g[i].r = r;
      g[l].to = i;
      g[r].to = i;
    }
  }
  deque<long long> q1 = {1};
  vector<long long> order;
  while (!q1.empty()) {
    long long v = q1.front();
    q1.pop_front();
    order.push_back(v);
    if (g[v].l != 0) {
      q1.push_back(g[v].l);
    }
    if (g[v].r != 0) {
      q1.push_back(g[v].r);
    }
  }
  reverse(order.begin(), order.end());
  for (auto v : order) {
    g[v].bit = g[v].val(g[g[v].l], g[g[v].r]);
  }
  vector<long long> ans(n + 1);
  q.empty();
  q.push_back(1);
  while (!q.empty()) {
    long long v = q.front();
    q.pop_front();
    if (v == 1) {
      ans[v] = !g[v].bit;
    } else {
      g[v].bit = !g[v].bit;
      long long to = g[v].to;
      if (g[to].val(g[g[to].l], g[g[to].r]) == g[to].bit) {
        ans[v] = g[1].bit;
      } else {
        ans[v] = ans[to];
      }
      g[v].bit = !g[v].bit;
    }
    if (g[v].l != 0) {
      q.push_back(g[v].l);
    }
    if (g[v].r != 0) {
      q.push_back(g[v].r);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (g[i].bit_op == op::IN) {
      cout << (long long)ans[i];
    }
  }
  cout << "\n";
}
