#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000005];
char op[1000005];
bool A[1000005][2], val[1000005];
void dfs(int u) {
  if (op[u] == 'I') return;
  dfs(adj[u][0]);
  if (op[u] == 'N') {
    val[u] = !val[adj[u][0]];
    return;
  }
  dfs(adj[u][1]);
  if (op[u] == 'A')
    val[u] = val[adj[u][0]] and val[adj[u][1]];
  else if (op[u] == 'O')
    val[u] = val[adj[u][0]] or val[adj[u][1]];
  else
    val[u] = val[adj[u][0]] xor val[adj[u][1]];
}
void dfs2(int u, int p) {
  if (u == 1)
    A[1][1 - val[1]] = 1 - val[1];
  else {
    if (op[p] == 'N')
      A[u][1 - val[u]] = A[p][val[u]];
    else {
      int v;
      if (adj[p][0] == u)
        v = adj[p][1];
      else
        v = adj[p][0];
      if (op[p] == 'A')
        A[u][1 - val[u]] = A[p][val[v] and (1 - val[u])];
      else if (op[p] == 'O')
        A[u][1 - val[u]] = A[p][val[v] or (1 - val[u])];
      else
        A[u][1 - val[u]] = A[p][val[v] xor (1 - val[u])];
    }
  }
  for (auto x : adj[u]) dfs2(x, u);
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, i, u, v;
  string s;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s;
    op[i] = s[0];
    if (s == "AND" or s == "OR" or s == "XOR") {
      cin >> u >> v;
      adj[i].push_back(u);
      adj[i].push_back(v);
    } else if (s == "NOT") {
      cin >> u;
      adj[i].push_back(u);
    } else {
      cin >> u;
      val[i] = u;
    }
  }
  dfs(1);
  for (i = 1; i <= n; i++) A[i][val[i]] = val[1];
  dfs2(1, 0);
  for (i = 1; i <= n; i++)
    if (op[i] == 'I') cout << A[i][1 - val[i]];
  return 0;
}
