#include <bits/stdc++.h>
using namespace std;
vector<int> gr[1000100];
string op[1000100];
int val[1000100];
int sch[1000100];
void dfs(int nod) {
  for (auto &x : gr[nod]) {
    dfs(x);
  }
  if (op[nod] == "IN") {
    return;
  }
  if (op[nod] == "AND") {
    val[nod] = (val[gr[nod][0]] and val[gr[nod][1]]);
  }
  if (op[nod] == "XOR") {
    val[nod] = (val[gr[nod][0]] xor val[gr[nod][1]]);
  }
  if (op[nod] == "OR") {
    val[nod] = (val[gr[nod][0]] or val[gr[nod][1]]);
  }
  if (op[nod] == "NOT") {
    val[nod] = !val[gr[nod][0]];
  }
}
void DFS(int nod) {
  if (op[nod] == "IN") {
    return;
  }
  if (op[nod] == "AND") {
    if (val[gr[nod][0]]) {
      sch[gr[nod][1]] = sch[nod];
    }
    if (val[gr[nod][1]]) {
      sch[gr[nod][0]] = sch[nod];
    }
  }
  if (op[nod] == "XOR") {
    sch[gr[nod][0]] = sch[nod];
    sch[gr[nod][1]] = sch[nod];
  }
  if (op[nod] == "OR") {
    if (!val[gr[nod][0]]) {
      sch[gr[nod][1]] = sch[nod];
    }
    if (!val[gr[nod][1]]) {
      sch[gr[nod][0]] = sch[nod];
    }
  }
  if (op[nod] == "NOT") {
    sch[gr[nod][0]] = sch[nod];
  }
  for (auto &x : gr[nod]) {
    DFS(x);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> op[i];
    if (op[i] == "IN") {
      cin >> val[i];
    }
    if (op[i] == "AND" || op[i] == "OR" || op[i] == "XOR") {
      int a, b;
      cin >> a >> b;
      gr[i].push_back(a);
      gr[i].push_back(b);
    }
    if (op[i] == "NOT") {
      int a;
      cin >> a;
      gr[i].push_back(a);
    }
  }
  dfs(1);
  sch[1] = 1;
  DFS(1);
  for (int i = 1; i <= n; i++) {
    if (op[i] == "IN") {
      if (sch[i]) {
        cout << (val[1] ^ 1);
      } else {
        cout << val[1];
      }
    }
  }
  return 0;
}
