#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 4;
vector<int> adj[N];
string a[N];
int val[N];
int dfs(int u) {
  if (a[u] == "AND" || a[u] == "OR" || a[u] == "XOR") {
    if (a[u] == "AND") {
      val[u] = 1;
      for (int v : adj[u]) {
        val[u] &= dfs(v);
      }
    } else if (a[u] == "XOR") {
      val[u] = 0;
      for (int v : adj[u]) {
        val[u] ^= dfs(v);
      }
    } else {
      val[u] = 0;
      for (int v : adj[u]) {
        val[u] |= dfs(v);
      }
    }
  } else {
    if (a[u] == "NOT") {
      val[u] = !dfs(adj[u][0]);
    }
  }
  return val[u];
}
int output[N][2];
void rec(int u) {
  if (a[u] == "AND" || a[u] == "OR" || a[u] == "XOR") {
    if (a[u] == "AND") {
      for (int t : {0, 1}) {
        int cur = t & val[adj[u][1]];
        output[adj[u][0]][t] = output[u][cur];
      }
      for (int t : {0, 1}) {
        int cur = t & val[adj[u][0]];
        output[adj[u][1]][t] = output[u][cur];
      }
    } else if (a[u] == "XOR") {
      for (int t : {0, 1}) {
        int cur = t ^ val[adj[u][1]];
        output[adj[u][0]][t] = output[u][cur];
      }
      for (int t : {0, 1}) {
        int cur = t ^ val[adj[u][0]];
        output[adj[u][1]][t] = output[u][cur];
      }
    } else {
      for (int t : {0, 1}) {
        int cur = t | val[adj[u][1]];
        output[adj[u][0]][t] = output[u][cur];
      }
      for (int t : {0, 1}) {
        int cur = t | val[adj[u][0]];
        output[adj[u][1]][t] = output[u][cur];
      }
    }
  } else {
    if (a[u] == "NOT") {
      for (int t : {0, 1}) {
        output[adj[u][0]][t] = output[u][!t];
      }
    }
  }
  for (int v : adj[u]) rec(v);
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == "AND" || a[i] == "OR" || a[i] == "XOR") {
      int u, v;
      cin >> u >> v;
      adj[i].push_back(u);
      adj[i].push_back(v);
    } else {
      int u;
      cin >> u;
      if (a[i] == "NOT") {
        adj[i].push_back(u);
      } else {
        val[i] = u;
      }
    }
  }
  int out = dfs(1);
  output[1][0] = 0;
  output[1][1] = 1;
  rec(1);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == "IN") {
      cout << output[i][!val[i]];
    }
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
