#include <bits/stdc++.h>
using namespace std;
int n;
string second[1000005];
int par[1000005];
int bit[1000005];
vector<int> g[1000005];
int dp[1000005][2];
void dfs(int u) {
  if (second[u] == "IN") return;
  for (int v : g[u]) dfs(v);
  if (second[u] == "NOT") bit[u] = !bit[g[u][0]];
  if (second[u] == "AND") bit[u] = bit[g[u][0]] & bit[g[u][1]];
  if (second[u] == "OR") bit[u] = bit[g[u][0]] | bit[g[u][1]];
  if (second[u] == "XOR") bit[u] = bit[g[u][0]] ^ bit[g[u][1]];
}
int findAns(int id, int b) {
  if (dp[id][b] != -1) return dp[id][b];
  int p = par[id];
  if (p == 0) return dp[id][b] = b;
  int d;
  if (second[p] == "NOT")
    d = !b;
  else {
    int c;
    if (g[p][0] != id)
      c = bit[g[p][0]];
    else
      c = bit[g[p][1]];
    if (second[p] == "AND") d = b & c;
    if (second[p] == "OR") d = b | c;
    if (second[p] == "XOR") d = b ^ c;
  }
  return dp[id][b] = findAns(p, d);
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> second[i];
    if (second[i] == "AND" || second[i] == "OR" || second[i] == "XOR") {
      int u, v;
      cin >> u >> v;
      g[i].push_back(u);
      g[i].push_back(v);
      par[u] = par[v] = i;
    }
    if (second[i] == "NOT") {
      int u;
      cin >> u;
      g[i].push_back(u);
      par[u] = i;
    }
    if (second[i] == "IN") cin >> bit[i];
  }
  dfs(1);
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= n; i++) {
    if (second[i] == "IN") {
      cout << findAns(i, !bit[i]);
    }
  }
  cout << endl;
}
