#include <bits/stdc++.h>
using namespace std;
struct node {
  string typ;
  int a, b;
};
vector<node> v;
vector<int> leaves;
vector<int> par;
vector<int> og;
vector<int> memo;
int get(int k) {
  if (v[k].typ == "IN")
    return og[k] = v[k].a;
  else if (v[k].typ == "AND") {
    int a = get(v[k].a), b = get(v[k].b);
    return og[k] = a && b;
  } else if (v[k].typ == "OR") {
    int a = get(v[k].a), b = get(v[k].b);
    return og[k] = a || b;
  } else if (v[k].typ == "XOR") {
    int a = get(v[k].a), b = get(v[k].b);
    return og[k] = a ^ b;
  }
  return og[k] = !get(v[k].a);
}
int prop(int k) {
  if (k == 1) return 1;
  if (memo[k] == 2)
    return 1;
  else if (memo[k] == 1)
    return 0;
  int p = par[k];
  if (v[p].typ == "NOT") {
    int r = prop(p);
    memo[k] = r + 1;
    return r;
  }
  if (v[p].typ == "AND") {
    if (v[p].a != k) swap(v[p].a, v[p].b);
    if (og[p] != ((!og[k]) && (og[v[p].b]))) {
      int r = prop(p);
      memo[k] = r + 1;
      return r;
    }
    memo[k] = 1;
    return 0;
  }
  if (v[p].typ == "OR") {
    if (v[p].a != k) swap(v[p].a, v[p].b);
    if (og[p] != ((!og[k]) || (og[v[p].b]))) {
      int r = prop(p);
      memo[k] = r + 1;
      return r;
    }
    memo[k] = 1;
    return 0;
  }
  int r = prop(p);
  memo[k] = r + 1;
  return r;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  v = vector<node>(n + 1);
  par = vector<int>(n + 1);
  memo = vector<int>(n + 1);
  og = vector<int>(n + 1);
  leaves.reserve(n);
  for (int i = 1; i <= n; ++i) {
    string s;
    int a, b;
    cin >> s >> a;
    if (s == "IN") {
      leaves.push_back(i);
      v[i] = node{s, a, 0};
    } else if (s == "NOT") {
      v[i] = node{s, a, 0};
      par[a] = i;
    } else {
      cin >> b;
      v[i] = node{s, a, b};
      par[a] = i;
      par[b] = i;
    }
  }
  int out = get(1);
  for (int i = 0; i < leaves.size(); ++i) {
    if (prop(leaves[i]))
      cout << !out;
    else
      cout << out;
  }
  cout << endl;
}
