#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1;
vector<long long> g[N];
long long bit[N], x, y, ans[N];
string s[N];
long long output(long long v) {
  if (s[v][0] == 'I')
    bit[v] = bit[v];
  else if (s[v][0] == 'X')
    bit[v] = output(g[v][0]) ^ output(g[v][1]);
  else if (s[v][0] == 'O')
    bit[v] = output(g[v][0]) | output(g[v][1]);
  else if (s[v][0] == 'A')
    bit[v] = output(g[v][0]) & output(g[v][1]);
  else
    bit[v] = !output(g[v][0]);
  return bit[v];
}
void change(long long v) {
  if (s[v][0] == 'I')
    ans[v] = 1;
  else if (s[v][0] == 'N')
    change(g[v][0]);
  else if (s[v][0] == 'A') {
    if (bit[g[v][0]]) change(g[v][1]);
    if (bit[g[v][1]]) change(g[v][0]);
  } else if (s[v][0] == 'O') {
    if (!bit[g[v][0]]) change(g[v][1]);
    if (!bit[g[v][1]]) change(g[v][0]);
  } else {
    change(g[v][0]);
    change(g[v][1]);
  }
}
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i][0] == 'N') {
      cin >> x;
      g[i].push_back(x);
    } else if (s[i][0] == 'I') {
      cin >> x;
      bit[i] = x;
    } else {
      cin >> x >> y;
      g[i].push_back(x);
      g[i].push_back(y);
    }
  }
  output(1);
  change(1);
  for (long long i = 1; i <= n; i++) {
    if (s[i][0] == 'I') cout << (ans[i] ^ bit[1]);
  }
}
