#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, inf = 1e9 + 7, MOD = 998244353;
const long long INF = 2e18 + 7;
vector<int> graph[N];
string type[N];
bool changeRes[N];
bool retVal[N];
bool op(bool a, bool b, string name) {
  if (name == "AND") return a && b;
  if (name == "XOR") return a ^ b;
  if (name == "OR") return a || b;
}
void merge(vector<int>& a, vector<int>& b) {
  if (a.size() < b.size()) swap(a, b);
  copy(b.begin(), b.end(), back_inserter(a));
}
vector<int> dfs(int v) {
  if (type[v] == "IN") {
    retVal[v] = graph[v].front();
    return {v};
  }
  if (type[v] == "NOT") {
    int u = graph[v].front();
    auto res = dfs(u);
    retVal[v] = !retVal[u];
    return res;
  }
  vector<int> res;
  int u1 = graph[v].front(), u2 = graph[v].back();
  auto l = dfs(u1), p = dfs(u2);
  retVal[v] = op(retVal[u1], retVal[u2], type[v]);
  auto temp = op(retVal[u1], !retVal[u2], type[v]);
  if (temp != retVal[v]) merge(res, p);
  temp = op(!retVal[u1], retVal[u2], type[v]);
  if (temp != retVal[v]) merge(res, l);
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    int a;
    cin >> s >> a;
    type[i] = s;
    if (s == "IN") {
      graph[i].push_back(a);
      continue;
    }
    --a;
    graph[i].push_back(a);
    if (s == "NOT") continue;
    cin >> a;
    --a;
    graph[i].push_back(a);
  }
  auto res = dfs(0);
  auto val = retVal[0];
  for (auto u : res) {
    changeRes[u] = true;
  }
  for (int i = 0; i < n; ++i) {
    if (type[i] == "IN") {
      if (val ^ changeRes[i])
        cout << '1';
      else
        cout << '0';
    }
  }
  return 0;
}
