#include <bits/stdc++.h>
using namespace std;
const int MN = 1000010;
int N;
vector<int> adj[MN], leaf;
string T[MN];
int V[MN], R[MN];
void dfs0(int u) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    dfs0(v);
  }
  if (T[u] == "IN") {
    R[u] = V[u];
  }
  if (T[u] == "AND") {
    R[u] = R[adj[u][0]] & R[adj[u][1]];
  }
  if (T[u] == "OR") {
    R[u] = R[adj[u][0]] | R[adj[u][1]];
  }
  if (T[u] == "XOR") {
    R[u] = R[adj[u][0]] ^ R[adj[u][1]];
  }
  if (T[u] == "NOT") {
    R[u] = !R[adj[u][0]];
  }
}
int dp[MN];
void dfs1(int u) {
  if (T[u] == "IN") {
    return;
  }
  if (T[u] == "AND") {
    dp[adj[u][0]] = R[adj[u][1]] == 1 ? dp[u] : 0;
    dp[adj[u][1]] = R[adj[u][0]] == 1 ? dp[u] : 0;
  }
  if (T[u] == "OR") {
    dp[adj[u][0]] = R[adj[u][1]] == 0 ? dp[u] : 0;
    dp[adj[u][1]] = R[adj[u][0]] == 0 ? dp[u] : 0;
  }
  if (T[u] == "XOR") {
    dp[adj[u][0]] = dp[u];
    dp[adj[u][1]] = dp[u];
  }
  if (T[u] == "NOT") {
    dp[adj[u][0]] = dp[u];
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    dfs1(v);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    if (T[i] == "IN") {
      cin >> V[i];
      leaf.push_back(i);
    }
    if (T[i] == "AND") {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      adj[i].push_back(a);
      adj[i].push_back(b);
    }
    if (T[i] == "OR") {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      adj[i].push_back(a);
      adj[i].push_back(b);
    }
    if (T[i] == "XOR") {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      adj[i].push_back(a);
      adj[i].push_back(b);
    }
    if (T[i] == "NOT") {
      int a;
      cin >> a;
      a--;
      adj[i].push_back(a);
    }
  }
  dfs0(0);
  dp[0] = 1;
  dfs1(0);
  for (int i = 0; i < leaf.size(); i++) {
    printf("%d", R[0] ^ dp[leaf[i]]);
  }
}
