#include <bits/stdc++.h>
using namespace std;
enum Type { AND, IN, XOR, NOT, OR };
struct Node {
  Type type;
  int left;
  int right;
  int defaultValue;
} nodes[1000000];
namespace Solution1 {
map<int, int> changeMap;
int buildDefaultValue(int id) {
  Node& node = nodes[id];
  if (node.type == IN) {
    return node.defaultValue;
  }
  int leftValue = buildDefaultValue(node.left);
  int rightValue = 0;
  if (node.right != -1) {
    rightValue = buildDefaultValue(node.right);
  }
  if (node.type == AND) {
    node.defaultValue = leftValue & rightValue;
  } else if (node.type == XOR) {
    node.defaultValue = leftValue ^ rightValue;
  } else if (node.type == NOT) {
    node.defaultValue = 1 - leftValue;
  } else if (node.type == OR) {
    node.defaultValue = leftValue | rightValue;
  }
  return node.defaultValue;
}
void buildChangeMap(int id, int root[2]) {
  Node& node = nodes[id];
  int newRoot[2];
  if (node.type == IN) {
    changeMap[id] = root[1 - node.defaultValue];
  } else if (node.type == AND) {
    int a0 = 0;
    int a1 = nodes[node.right].defaultValue == 1 ? 1 : 0;
    newRoot[0] = root[a0];
    newRoot[1] = root[a1];
    buildChangeMap(node.left, newRoot);
    a1 = nodes[node.left].defaultValue == 1 ? 1 : 0;
    newRoot[1] = root[a1];
    buildChangeMap(node.right, newRoot);
  } else if (node.type == OR) {
    int a0 = nodes[node.right].defaultValue;
    int a1 = 1;
    newRoot[0] = root[a0];
    newRoot[1] = root[a1];
    buildChangeMap(node.left, newRoot);
    a0 = nodes[node.left].defaultValue;
    newRoot[0] = root[a0];
    buildChangeMap(node.right, newRoot);
  } else if (node.type == XOR) {
    int a0 = nodes[node.right].defaultValue;
    int a1 = 1 - a0;
    newRoot[0] = root[a0];
    newRoot[1] = root[a1];
    buildChangeMap(node.left, newRoot);
    a0 = nodes[node.left].defaultValue;
    a1 = 1 - a0;
    newRoot[0] = root[a0];
    newRoot[1] = root[a1];
    buildChangeMap(node.right, newRoot);
  } else if (node.type == NOT) {
    newRoot[0] = root[1];
    newRoot[1] = root[0];
    buildChangeMap(node.left, newRoot);
  }
}
string getResult() {
  buildDefaultValue(0);
  changeMap.clear();
  int root[2] = {0, 1};
  buildChangeMap(0, root);
  string s;
  for (auto& pair : changeMap) {
    s.push_back(pair.second ? '1' : '0');
  }
  return s;
}
}  // namespace Solution1
using namespace Solution1;
Type getType(char* s) {
  if (strcmp(s, "AND") == 0) return AND;
  if (strcmp(s, "IN") == 0) return IN;
  if (strcmp(s, "XOR") == 0) return XOR;
  if (strcmp(s, "NOT") == 0) return NOT;
  if (strcmp(s, "OR") == 0) return OR;
  return IN;
}
int main() {
  int n;
  while (scanf("%d", &n) == 1 && n > 0) {
    char s[8];
    int arg1, arg2;
    for (int i = 0; i < n; ++i) {
      scanf("%s%d", s, &arg1);
      Type type = getType(s);
      nodes[i].type = type;
      if (type == IN) {
        nodes[i].defaultValue = arg1;
      } else {
        nodes[i].left = arg1 - 1;
        if (type == AND || type == XOR || type == OR) {
          scanf("%d", &arg2);
          nodes[i].right = arg2 - 1;
        } else {
          nodes[i].right = -1;
        }
      }
    }
    string res = getResult();
    printf("%s\n", res.c_str());
  }
}
