#include <bits/stdc++.h>
using namespace std;
enum Op { NOT, AND, IN, XOR, OR };
struct Node {
  Op op;
  int input[2];
  int output;
  int cache[2];
  int value;
  int get() {
    if (value == -1) {
      return run();
    } else {
      return value;
    }
  }
  int run();
} nodes[1000006];
int Node::run() {
  int ret;
  if (op == NOT) {
    ret = !nodes[input[0]].get();
  } else if (op == OR) {
    ret = nodes[input[0]].get() | nodes[input[1]].get();
  } else if (op == XOR) {
    ret = nodes[input[0]].get() ^ nodes[input[1]].get();
  } else if (op == AND) {
    ret = nodes[input[0]].get() & nodes[input[1]].get();
  } else if (op == IN) {
    ret = value;
  }
  value = ret;
  return ret;
}
int solve(int i, int v) {
  if (i == 1) {
    return v;
  }
  if (nodes[i].cache[v] != -1) {
    return nodes[i].cache[v];
  }
  int ov = nodes[i].value;
  int ret = nodes[i].cache[ov];
  nodes[i].value = v;
  Node &nxt = nodes[nodes[i].output];
  int nxt_v = nxt.value;
  if (nxt.run() != nxt_v) {
    nxt.value = nxt_v;
    ret = solve(nodes[i].output, !nxt_v);
  }
  nxt.value = nxt_v;
  nodes[i].value = ov;
  nodes[i].cache[v] = ret;
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> ins;
  for (int i = 1; i <= n; i++) {
    nodes[i].cache[0] = -1;
    nodes[i].cache[1] = -1;
    nodes[i].value = -1;
    char t[5];
    int a, b;
    scanf("%s%d", t, &a);
    nodes[a].output = i;
    switch (t[0]) {
      case 'I':
        nodes[i].op = IN;
        nodes[i].value = a;
        ins.push_back(i);
        break;
      case 'N':
        nodes[i].op = NOT;
        nodes[i].input[0] = a;
        break;
      case 'O':
        nodes[i].op = OR;
        nodes[i].input[0] = a;
        scanf("%d", &b);
        nodes[i].input[1] = b;
        nodes[b].output = i;
        break;
      case 'X':
        nodes[i].op = XOR;
        nodes[i].input[0] = a;
        scanf("%d", &b);
        nodes[i].input[1] = b;
        nodes[b].output = i;
        break;
      case 'A':
        nodes[i].op = AND;
        nodes[i].input[0] = a;
        scanf("%d", &b);
        nodes[i].input[1] = b;
        nodes[b].output = i;
        break;
    }
  }
  nodes[1].run();
  for (int i = 1; i <= n; i++) {
    int v = nodes[i].value;
    nodes[i].cache[v] = nodes[1].value;
  }
  for (auto in : ins) {
    int ans = solve(in, !nodes[in].value);
    printf("%d", ans);
  }
  puts("");
}
