#include <bits/stdc++.h>
using namespace std;
enum Op {
  IN = 0,
  AND,
  OR,
  XOR,
  NOT,
};
struct Node {
  Node(Op o = Op::IN, int i = -1, int v = -1, int p = -1, int l = -1,
       int r = -1)
      : op(o), id(i), val(v), parent(p), leftChild(l), rightChild(r) {}
  Op op;
  int id;
  int parent;
  int leftChild;
  int rightChild;
  int val;
};
void parse(int n, vector<Node>& res) {
  res.resize(n);
  for (int i = 0; i < n; ++i) {
    char buf[10] = {0};
    scanf("%s", buf);
    Node& node = res[i];
    node.id = i;
    string s(buf);
    if (s == "IN") {
      node.op = Op::IN;
      int v;
      scanf("%d", &v);
      node.val = v;
    } else {
      if (s == "AND") {
        node.op = Op::AND;
      } else if (s == "OR") {
        node.op = Op::OR;
      } else if (s == "XOR") {
        node.op = Op::XOR;
      } else {
        assert(s == "NOT");
        node.op = Op::NOT;
      }
      if (node.op == Op::NOT) {
        scanf("%d", &(node.leftChild));
        --node.leftChild;
        res[node.leftChild].parent = i;
      } else {
        scanf("%d%d", &(node.leftChild), &(node.rightChild));
        --node.leftChild;
        --node.rightChild;
        res[node.leftChild].parent = i;
        res[node.rightChild].parent = i;
      }
    }
  }
}
class Solution {
 public:
  Solution(vector<Node>& ns) : nodes(ns), root(0) {}
  void preprocess() {
    calcAll(root);
    buildAnswerTable();
  }
  string rebuild() {
    string res;
    res.reserve(nodes.size());
    for (auto& node : nodes) {
      int i = node.id;
      if (node.op != Op::IN) {
        continue;
      }
      if (node.val == 0) {
        res += '0' + ansTable[i].second;
      } else {
        res += '0' + ansTable[i].first;
      }
    }
    return res;
  }

 private:
  int root;
  vector<Node> nodes;
  vector<pair<int, int>> ansTable;
  int calc(Op op, int l, int r) {
    int res = 0;
    switch (op) {
      case Op::IN:
        res = l;
        break;
      case Op::AND:
        res = l & r;
        break;
      case Op::OR:
        res = l | r;
        break;
      case Op::XOR:
        res = l ^ r;
        break;
      case Op::NOT:
        res = l ^ 1;
        break;
      default:;
    }
    return res;
  }
  int calc(int u) {
    int l = nodes[u].leftChild;
    int r = nodes[u].rightChild;
    if (nodes[u].op == Op::AND) {
      nodes[u].val = nodes[l].val & nodes[r].val;
    } else if (nodes[u].op == Op::OR) {
      nodes[u].val = nodes[l].val | nodes[r].val;
    } else if (nodes[u].op == Op::XOR) {
      nodes[u].val = nodes[l].val ^ nodes[r].val;
    } else if (nodes[u].op == Op::NOT) {
      nodes[u].val = nodes[l].val ^ 1;
    }
    return nodes[u].val;
  }
  void calcAll(int u) {
    if (nodes[u].op == Op::IN || u == -1) {
      return;
    }
    int l = nodes[u].leftChild;
    int r = nodes[u].rightChild;
    if (l != -1) {
      calcAll(l);
    }
    if (r != -1) {
      calcAll(r);
    }
    calc(u);
  }
  void dfs(int u, vector<int>& ord) {
    if (u == -1) {
      return;
    }
    dfs(nodes[u].leftChild, ord);
    dfs(nodes[u].rightChild, ord);
    ord.push_back(u);
  }
  void topoSort(vector<int>& ord) {
    ord.clear();
    ord.reserve(nodes.size());
    dfs(root, ord);
  }
  void buildAnswerTable() {
    vector<int> ord;
    topoSort(ord);
    reverse(ord.begin(), ord.end());
    ansTable.clear();
    ansTable.resize(nodes.size());
    for (auto u : ord) {
      if (nodes[u].parent == -1) {
        assert(u == root);
        ansTable[u].first = 0;
        ansTable[u].second = 1;
      } else {
        int p = nodes[u].parent;
        int other = -1;
        if (nodes[p].leftChild == u) {
          other = nodes[p].rightChild;
        } else {
          other = nodes[p].leftChild;
        }
        int ans0 = calc(nodes[p].op, 0, nodes[other].val);
        int ans1 = calc(nodes[p].op, 1, nodes[other].val);
        ansTable[u].first = ans0 == 0 ? ansTable[p].first : ansTable[p].second;
        ansTable[u].second = ans1 == 0 ? ansTable[p].first : ansTable[p].second;
      }
    }
  }
};
int main(int argc, char** argv) {
  int n;
  scanf("%d", &n);
  vector<Node> nodes;
  parse(n, nodes);
  Solution sol(nodes);
  sol.preprocess();
  auto res = sol.rebuild();
  printf("%s\n", res.c_str());
  return 0;
}
