#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
void redirect() {}
int n;
struct node {
  string opt;
  int lson, rson;
} a[N];
int f[N], val[N];
int getf(int x) { return f[x] == x ? f[x] : f[x] = getf(f[x]); }
bool dfs(int x) {
  string s = a[x].opt;
  int l = a[x].lson, r = a[x].rson;
  if (s == "AND") {
    bool lres = dfs(l), rres = dfs(r);
    if (lres && rres) f[l] = x, f[r] = x;
    if (lres && !rres) f[r] = x;
    if (!lres && rres) f[l] = x;
    if (lres && rres)
      return true;
    else
      return false;
  } else if (s == "OR") {
    bool lres = dfs(l), rres = dfs(r);
    if (!lres && !rres) f[l] = x, f[r] = x;
    if (lres && !rres) f[l] = x;
    if (!lres && rres) f[r] = x;
    if (lres || rres)
      return true;
    else
      return false;
  } else if (s == "XOR") {
    bool lres = dfs(l), rres = dfs(r);
    if (lres && rres) f[l] = x, f[r] = x;
    if (!lres && !rres) f[l] = x, f[r] = x;
    if (lres && !rres) f[l] = x, f[r] = x;
    if (!lres && rres) f[l] = x, f[r] = x;
    if (lres ^ rres)
      return true;
    else
      return false;
  } else if (s == "NOT") {
    bool lres = dfs(l);
    f[l] = x;
    return !lres;
  } else if (s == "IN") {
    return (bool)l;
  }
}
int main() {
  redirect();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    cin >> a[i].opt;
    if (a[i].opt == "IN" || a[i].opt == "NOT")
      cin >> a[i].lson;
    else
      cin >> a[i].lson >> a[i].rson;
  }
  bool res = dfs(1);
  for (int i = 1; i <= n; i++) {
    if (a[i].opt == "IN") {
      int f = getf(i);
      if (f == 1) {
        printf("%d", !res);
      } else {
        printf("%d", res);
      }
    }
  }
  return 0;
}
