#include <bits/stdc++.h>
using namespace std;
const int dd = (int)2e6 + 7;
int ans[dd];
int val[dd];
int go[dd][2];
string tp[dd];
void calc(int v) {
  if (tp[v] == "IN") return;
  for (int i = 0; i < 2; i++) calc(go[v][i]);
  if (tp[v] == "AND") val[v] = val[go[v][0]] & val[go[v][1]];
  if (tp[v] == "OR") val[v] = val[go[v][0]] | val[go[v][1]];
  if (tp[v] == "XOR") val[v] = val[go[v][0]] ^ val[go[v][1]];
}
void dfs(int v, int cur) {
  if (tp[v] == "IN") {
    if (cur == -1)
      ans[v] = val[0] ^ 1;
    else
      ans[v] = cur;
  } else {
    for (int i = 0; i < 2; i++) {
      int cv = cur;
      if (cv == -1) {
        if (tp[v] == "OR" && val[go[v][i ^ 1]] == 1) cv = val[0];
        if (tp[v] == "AND" && val[go[v][i ^ 1]] == 0) cv = val[0];
      }
      dfs(go[v][i], cv);
    }
  }
}
void solve() {
  int n;
  cin >> n;
  int nv = n;
  for (auto &i : go) i[0] = i[1] = -1;
  fill(val, val + dd, -1);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    tp[i] = s;
    if (s == "IN") {
      int x;
      cin >> x;
      val[i] = x;
    }
    if (s == "AND" || s == "OR" || s == "XOR") {
      int a, b;
      cin >> a >> b;
      go[i][0] = a - 1;
      go[i][1] = b - 1;
    }
    if (s == "NOT") {
      int x;
      cin >> x;
      go[i][0] = x - 1;
      go[i][1] = nv;
      val[nv] = 1;
      tp[i] = "XOR", tp[nv] = "IN";
      nv++;
    }
  }
  calc(0);
  dfs(0, -1);
  for (int v = 0; v < n; v++) 42;
  for (int v = 0; v < n; v++)
    if (tp[v] == "IN") cout << ans[v];
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
