#include <bits/stdc++.h>
using namespace std;
struct node {
  string type;
  int val;
  int left, right;
};
vector<int> vals;
vector<node> nodes;
vector<int> depths;
vector<list<int>> changes;
void dfs(int x, int depth) {
  depths[x] = depth;
  if (nodes[x].type == "IN")
    vals[x] = nodes[x].val;
  else {
    dfs(nodes[x].left, depth + 1);
    if (nodes[x].right >= 0) dfs(nodes[x].right, depth + 1);
    if (nodes[x].type == "AND")
      vals[x] = vals[nodes[x].left] & vals[nodes[x].right];
    else if (nodes[x].type == "OR")
      vals[x] = vals[nodes[x].left] | vals[nodes[x].right];
    else if (nodes[x].type == "XOR")
      vals[x] = vals[nodes[x].left] ^ vals[nodes[x].right];
    else if (nodes[x].type == "NOT")
      vals[x] = 1 - vals[nodes[x].left];
  }
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (argc == 2 && atoi(argv[1]) == 123456789)
    freopen("d:\\code\\cpp\\stdin", "r", stdin);
  int n;
  cin >> n;
  vals.resize(n);
  nodes.resize(n);
  depths.resize(n);
  int nrleafs = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    nodes[i].type = s;
    if (s == "IN") {
      cin >> nodes[i].val;
      nrleafs++;
    } else if (s == "NOT") {
      int li;
      cin >> li;
      li--;
      nodes[i].left = li;
      nodes[i].right = -1;
    } else {
      int li, ri;
      cin >> li >> ri;
      li--;
      ri--;
      nodes[i].left = li;
      nodes[i].right = ri;
    }
  }
  dfs(0, 0);
  vector<pair<int, int>> order;
  for (int i = 0; i < n; i++) order.push_back(make_pair(-depths[i], i));
  sort(order.begin(), order.end());
  changes.resize(n);
  for (int i = 0; i < n; i++) {
    int x = order[i].second;
    if (nodes[x].type == "IN")
      changes[x].push_back(x);
    else {
      if (nodes[x].type == "AND") {
        if (((1 - vals[nodes[x].left]) & vals[nodes[x].right]) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].left]);
        if ((vals[nodes[x].left] & (1 - vals[nodes[x].right])) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].right]);
      } else if (nodes[x].type == "OR") {
        if (((1 - vals[nodes[x].left]) | vals[nodes[x].right]) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].left]);
        if ((vals[nodes[x].left] | (1 - vals[nodes[x].right])) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].right]);
      } else if (nodes[x].type == "XOR") {
        if (((1 - vals[nodes[x].left]) ^ vals[nodes[x].right]) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].left]);
        if ((vals[nodes[x].left] ^ (1 - vals[nodes[x].right])) != vals[x])
          changes[x].splice(changes[x].begin(), changes[nodes[x].right]);
      } else if (nodes[x].type == "NOT") {
        changes[x].splice(changes[x].begin(), changes[nodes[x].left]);
      }
    }
  }
  vector<int> xx;
  for (int x : changes[0]) xx.push_back(x);
  sort(xx.begin(), xx.end());
  int posx = 0;
  for (int i = 0; i < n; i++)
    if (nodes[i].type == "IN") {
      if (posx < xx.size() && xx[posx] == i) {
        cout << 1 - vals[0];
        posx++;
      } else
        cout << vals[0];
    }
  cout << endl;
  return 0;
}
