#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(ios::badbit | ios::failbit);
  int n;
  cin >> n;
  vector<vector<int>> adj(n);
  vector<int> init(n, -1), leaves;
  vector<string> type(n);
  for (auto u = 0; u < n; ++u) {
    cin >> type[u];
    if (type[u] == "AND" || type[u] == "OR" || type[u] == "XOR") {
      int v, w;
      cin >> v >> w, --v, --w;
      adj[u].push_back(v), adj[u].push_back(w);
    } else if (type[u] == "NOT") {
      int v;
      cin >> v, --v;
      adj[u].push_back(v);
    } else {
      cin >> init[u];
      leaves.push_back(u);
    }
  }
  sort(leaves.begin(), leaves.end());
  function<void(int)> dfs = [&](int u) {
    if (type[u] == "AND" || type[u] == "OR" || type[u] == "XOR") {
      for (auto v : adj[u]) {
        dfs(v);
      }
      auto merge = [&](int x, int y) {
        return type[u] == "AND" ? x & y : type[u] == "OR" ? x | y : x ^ y;
      };
      init[u] = merge(init[adj[u][0]], init[adj[u][1]]);
    } else if (type[u] == "NOT") {
      int v = adj[u][0];
      dfs(v);
      init[u] = !init[v];
    }
  };
  dfs(0);
  42;
  vector<array<int, 2>> dp(n, {0, 1});
  function<void(int)> solve = [&](int u) {
    if (type[u] == "AND" || type[u] == "OR" || type[u] == "XOR") {
      auto merge = [&](int x, int y) {
        return type[u] == "AND" ? x & y : type[u] == "OR" ? x | y : x ^ y;
      };
      for (auto v : adj[u]) {
        int w = v ^ adj[u][0] ^ adj[u][1];
        dp[v] = {dp[u][merge(0, init[w])], dp[u][merge(1, init[w])]};
        solve(v);
      }
    } else if (type[u] == "NOT") {
      int v = adj[u][0];
      dp[v] = {dp[u][1], dp[u][0]};
      solve(v);
    }
  };
  solve(0);
  for (auto u : leaves) {
    cout << dp[u][!init[u]];
  }
  cout << "\n";
  return 0;
}
