#include <bits/stdc++.h>
#pragma GCC optimize "03"
using namespace std;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
map<int, string> type;
int a[N];
vector<int> g[N];
int dp[N][2];
void dfs(int u) {
  if (g[u].empty()) return;
  for (int i : g[u]) dfs(i);
  if (type[u] == "NOT") a[u] = (a[g[u][0]] ^ 1);
  if (type[u] == "AND") a[u] = (a[g[u][0]] & a[g[u][1]]);
  if (type[u] == "OR") a[u] = (a[g[u][0]] | a[g[u][1]]);
  if (type[u] == "XOR") a[u] = (a[g[u][0]] ^ a[g[u][1]]);
}
void dfs1(int u) {
  if (g[u].empty()) return;
  if (type[u] == "NOT") {
    dp[g[u][0]][a[g[u][0]]] = a[1];
    dp[g[u][0]][a[g[u][0]] ^ 1] = dp[u][a[g[u][0]]];
  }
  if (type[u] == "AND") {
    dp[g[u][0]][a[g[u][0]]] = a[1];
    dp[g[u][1]][a[g[u][1]]] = a[1];
    int x = ((a[g[u][0]] ^ 1) & a[g[u][1]]);
    dp[g[u][0]][a[g[u][0]] ^ 1] = dp[u][x];
    x = ((a[g[u][0]]) & (a[g[u][1]] ^ 1));
    dp[g[u][1]][a[g[u][1]] ^ 1] = dp[u][x];
  }
  if (type[u] == "OR") {
    dp[g[u][0]][a[g[u][0]]] = a[1];
    dp[g[u][1]][a[g[u][1]]] = a[1];
    int x = ((a[g[u][0]] ^ 1) | a[g[u][1]]);
    dp[g[u][0]][a[g[u][0]] ^ 1] = dp[u][x];
    x = ((a[g[u][0]]) | (a[g[u][1]] ^ 1));
    dp[g[u][1]][a[g[u][1]] ^ 1] = dp[u][x];
  }
  if (type[u] == "XOR") {
    dp[g[u][0]][a[g[u][0]]] = a[1];
    dp[g[u][1]][a[g[u][1]]] = a[1];
    int x = ((a[g[u][0]] ^ 1) ^ a[g[u][1]]);
    dp[g[u][0]][a[g[u][0]] ^ 1] = dp[u][x];
    x = ((a[g[u][0]]) ^ (a[g[u][1]] ^ 1));
    dp[g[u][1]][a[g[u][1]] ^ 1] = dp[u][x];
  }
  for (int i : g[u]) dfs1(i);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    type[i] = s;
    if (s == "IN") {
      int u;
      cin >> u;
      a[i] = u;
    } else if (s == "NOT") {
      int u;
      cin >> u;
      g[i].push_back(u);
    } else {
      int u, v;
      cin >> u >> v;
      g[i].push_back(u);
      g[i].push_back(v);
    }
  }
  dfs(1);
  dp[1][1] = 1;
  dp[1][0] = 0;
  dfs1(1);
  for (int i = 1; i <= n; i++) {
    if (type[i] == "IN") cout << dp[i][a[i] ^ 1];
  }
  return 0;
}
