#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 9;
int n, par[MX], val[MX], dp[MX][2], x, y;
vector<int> v[MX], nodes;
string s[MX];
char oo[MX];
int dfs(int x, int p) {
  if (s[x] == "IN") return val[x];
  vector<int> v1;
  for (auto pp : v[x]) {
    v1.push_back(dfs(pp, x));
  }
  if (s[x] == "AND") return val[x] = (v1[0] & v1[1]);
  if (s[x] == "OR") return val[x] = (v1[0] | v1[1]);
  if (s[x] == "XOR") return val[x] = (v1[0] ^ v1[1]);
  if (s[x] == "NOT") return val[x] = (!v1[0]);
}
int DP(int x, int bit) {
  if (x == 1) return bit;
  int &ret = dp[x][bit];
  if (ret != -1) return ret;
  int y = par[x];
  if (s[y] == "AND") {
    int bit1 = 0;
    for (auto pp : v[y]) {
      if (pp == x) continue;
      bit1 = val[pp];
    }
    return ret = DP(y, bit & bit1);
  }
  if (s[y] == "OR") {
    int bit1 = 0;
    for (auto pp : v[y]) {
      if (pp == x) continue;
      bit1 = val[pp];
    }
    return ret = DP(y, bit | bit1);
  }
  if (s[y] == "XOR") {
    int bit1 = 0;
    for (auto pp : v[y]) {
      if (pp == x) continue;
      bit1 = val[pp];
    }
    return ret = DP(y, bit ^ bit1);
  }
  if (s[y] == "NOT") {
    return ret = DP(y, !bit);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", &oo);
    s[i] = oo;
    if (s[i] == "IN") {
      scanf("%d", &x);
      val[i] = x;
      nodes.push_back(i);
      continue;
    }
    if (s[i] == "NOT") {
      scanf("%d", &x);
      par[x] = i;
      v[i].push_back(x);
      continue;
    }
    scanf("%d%d", &x, &y);
    v[i].push_back(x);
    v[i].push_back(y);
    par[x] = i;
    par[y] = i;
  }
  dfs(1, -1);
  string ans = "";
  memset(dp, -1, sizeof(dp));
  for (auto pp : nodes) {
    if (DP(pp, !val[pp]))
      ans += '1';
    else
      ans += '0';
  }
  cout << ans << endl;
}
