#include <bits/stdc++.h>
using namespace std;
vector<long> getVector(int n) {
  vector<long> result(n);
  for (int i = 0; i < n; i++) cin >> result[i];
  return result;
}
vector<vector<long long>> getVector2ll(int n, int m) {
  vector<vector<long long>> result(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long curr;
      cin >> curr;
      result[i].push_back(curr);
    }
  }
  return result;
}
void printVector(vector<int> a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
}
long GCD(long a, long b) {
  long c;
  if (a < b) swap(a, b);
  while (b != 0) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
class block {
 public:
  string type;
  int child1;
  int child2;
  bool val;
  int nbChilds;
  block(string type, int child) {
    this->type = type;
    this->child1 = child;
    this->val = (bool)child;
    if (type == "IN")
      this->nbChilds = 0;
    else
      this->nbChilds = 1;
  }
  block(string type, int child1, int child2) {
    this->type = type;
    this->child1 = child1;
    this->child2 = child2;
    this->nbChilds = 2;
  }
};
vector<block> blocks;
void calcDefault(vector<bool> &defaultVals, int i) {
  block b = blocks[i];
  if (b.type == "IN")
    defaultVals[i] = b.val;
  else if (b.type == "NOT") {
    calcDefault(defaultVals, b.child1);
    defaultVals[i] = !defaultVals[b.child1];
  } else {
    calcDefault(defaultVals, b.child1);
    calcDefault(defaultVals, b.child2);
    if (b.type == "AND")
      defaultVals[i] = defaultVals[b.child1] && defaultVals[b.child2];
    else if (b.type == "OR")
      defaultVals[i] = defaultVals[b.child1] || defaultVals[b.child2];
    else
      defaultVals[i] = defaultVals[b.child1] ^ defaultVals[b.child2];
  }
}
vector<int> result;
void search(vector<bool> &defaultVals, int i) {
  block b = blocks[i];
  if (b.type == "IN")
    result.push_back(i);
  else if (b.type == "NOT")
    search(defaultVals, b.child1);
  else {
    if (b.type == "AND") {
      if (defaultVals[b.child1]) search(defaultVals, b.child2);
      if (defaultVals[b.child2]) search(defaultVals, b.child1);
    } else if (b.type == "OR") {
      if (!defaultVals[b.child1]) search(defaultVals, b.child2);
      if (!defaultVals[b.child2]) search(defaultVals, b.child1);
    } else {
      search(defaultVals, b.child1);
      search(defaultVals, b.child2);
    }
  }
}
int main() {
  int n;
  cin >> n;
  blocks.push_back(block("", 0));
  for (int i = 0; i < n; i++) {
    string type;
    cin >> type;
    if (type == "NOT" || type == "IN") {
      int child;
      cin >> child;
      blocks.push_back(block(type, child));
    } else {
      int child1, child2;
      cin >> child1;
      cin >> child2;
      blocks.push_back(block(type, child1, child2));
    }
  }
  vector<bool> defaultVals(n + 1);
  calcDefault(defaultVals, 1);
  search(defaultVals, 1);
  vector<int> values(n + 1, -1);
  for (int i = 0; i <= n; i++)
    if (blocks[i].type == "IN") values[i] = (int)defaultVals[1];
  for (int i = 0; i < result.size(); i++)
    values[result[i]] = 1 - (int)defaultVals[1];
  for (int i = 0; i <= n; i++)
    if (values[i] != -1) cout << values[i];
}
