#include <bits/stdc++.h>
using namespace std;
long long int n, val[1000005], dp[1000005], par[1000005], ch[1000005],
    len[1000005];
vector<long long int> g[1000005];
long long int fin[1000005];
long long int dfs(long long int st, long long int dpt = 0) {
  if (g[st].empty()) return dp[st] = val[st];
  len[st] = dpt;
  for (long long int v : g[st]) dfs(v, dpt + 1);
  if (val[st] == 2) return dp[st] = (dp[g[st][0]] & dp[g[st][1]]);
  if (val[st] == 3) return dp[st] = (dp[g[st][0]] | dp[g[st][1]]);
  if (val[st] == 5) return dp[st] = (dp[g[st][0]] ^ dp[g[st][1]]);
  if (val[st] == 4) return dp[st] = (!dp[g[st][0]]);
}
long long int tot0 = 0, ans;
void getans(long long int st) {
  if (ch[st] == 0) tot0++;
  if (g[st].empty()) {
    if (tot0)
      fin[st] = ans;
    else
      fin[st] = !ans;
  }
  for (long long int v : g[st]) getans(v);
  if (ch[st] == 0) tot0--;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    if (s == "AND") {
      val[i] = 2;
      long long int u, v;
      cin >> u >> v;
      g[i].push_back(u);
      g[i].push_back(v);
      par[u] = i;
      par[v] = i;
    }
    if (s == "OR") {
      val[i] = 3;
      long long int u, v;
      cin >> u >> v;
      g[i].push_back(u);
      g[i].push_back(v);
      par[u] = i;
      par[v] = i;
    }
    if (s == "XOR") {
      val[i] = 5;
      long long int u, v;
      cin >> u >> v;
      g[i].push_back(u);
      g[i].push_back(v);
      par[u] = i;
      par[v] = i;
    }
    if (s == "NOT") {
      val[i] = 4;
      long long int u;
      cin >> u;
      g[i].push_back(u);
      par[u] = i;
    }
    if (s == "IN") {
      cin >> val[i];
    }
  }
  ans = dfs(1);
  ch[1] = 1;
  for (long long int i = 2; i <= n; ++i) {
    long long int pr = par[i];
    if (val[pr] == 4)
      ch[i] = 1;
    else {
      long long int oc = g[pr][0];
      if (oc == i) oc = g[pr][1];
      if (val[pr] == 3) {
        if (dp[pr] == 1 && dp[oc] == 0) ch[i] = 1;
        if (dp[pr] == 0) ch[i] = 1;
      } else if (val[pr] == 2) {
        if (dp[pr] == 1) ch[i] = 1;
        if (dp[pr] == 0 && dp[oc] == 1) ch[i] = 1;
      } else {
        ch[i] = 1;
      }
    }
  }
  getans(1);
  for (long long int i = 1; i <= n; ++i)
    if (g[i].empty()) cout << fin[i];
  cout << '\n';
}
