#include <bits/stdc++.h>
using namespace std;
typedef struct Node {
  Node* left;
  Node* right;
  Node* parent;
  int _type;
  bool val;
  bool evaled;
  bool leftChild;
  bool flipped;
  int index;
  Node(int t) {
    left = nullptr;
    right = nullptr;
    parent = nullptr;
    leftChild = false;
    evaled = false;
    flipped = false;
    index = t;
  }
  bool eval() {
    bool ll, rr;
    switch (_type) {
      case 0:
        return val;
      case 1:
        if (left->evaled)
          ll = left->val;
        else
          ll = left->eval();
        if (right->evaled)
          rr = right->val;
        else
          rr = right->eval();
        val = ll & rr;
        evaled = true;
        return val;
      case 2:
        if (left->evaled)
          ll = left->val;
        else
          ll = left->eval();
        if (right->evaled)
          rr = right->val;
        else
          rr = right->eval();
        val = ll | rr;
        evaled = true;
        return val;
      case 3:
        if (left->evaled)
          ll = left->val;
        else
          ll = left->eval();
        if (right->evaled)
          rr = right->val;
        else
          rr = right->eval();
        val = ll ^ rr;
        evaled = true;
        return val;
      case 4:
        if (left->evaled)
          ll = left->val;
        else
          ll = left->eval();
        val = !ll;
        evaled = true;
        return val;
      default:
        return val;
    }
  }
} Node;
void topdown(Node* node) {
  switch (node->_type) {
    case 0:
      node->flipped = true;
      break;
    case 1:
      if (node->val) {
        topdown(node->left);
        topdown(node->right);
      } else {
        if (node->left->val)
          topdown(node->right);
        else if (node->right->val)
          topdown(node->left);
      }
      break;
    case 2:
      if (node->val) {
        if (node->left->val && !node->right->val)
          topdown(node->left);
        else if (!node->left->val && node->right->val)
          topdown(node->right);
      } else {
        topdown(node->left);
        topdown(node->right);
      }
      break;
    case 3:
      topdown(node->left);
      topdown(node->right);
      break;
    case 4:
      topdown(node->left);
      break;
    default:
      break;
  }
}
Node* root;
int main() {
  int N;
  cin >> N;
  vector<Node*> nodes(N + 1);
  for (int i = 1; i <= N; i++) nodes[i] = new Node(i);
  vector<Node*> leaves(N + 1);
  int n = 0;
  string st;
  int l, r, t;
  for (int i = 1; i <= N; i++) {
    cin >> st;
    if (st[0] == 'I') {
      nodes[i]->_type = 0;
      cin >> t;
      nodes[i]->val = (t == 1);
      leaves[n] = nodes[i];
      n = n + 1;
      nodes[i]->evaled = true;
    } else if (st[0] == 'A') {
      nodes[i]->_type = 1;
      cin >> l >> r;
      nodes[i]->left = nodes[l];
      nodes[i]->right = nodes[r];
    } else if (st[0] == 'O') {
      nodes[i]->_type = 2;
      cin >> l >> r;
      nodes[i]->left = nodes[l];
      nodes[i]->right = nodes[r];
    } else if (st[0] == 'X') {
      nodes[i]->_type = 3;
      cin >> l >> r;
      nodes[i]->left = nodes[l];
      nodes[i]->right = nodes[r];
    } else if (st[0] == 'N') {
      nodes[i]->_type = 4;
      cin >> t;
      nodes[i]->left = nodes[t];
    }
  }
  root = nodes[1];
  root->eval();
  topdown(root);
  bool output = root->val;
  for (int i = 0; i < n; i++)
    if (leaves[i]->flipped)
      cout << !output;
    else
      cout << output;
  return 0;
}
