#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e6 + 100;
char s[N][10];
int a[N];
int b[N];
vector<int> p[N];
int dp[N];
int dfs(int x) {
  int r = 0, r1 = 0;
  if (s[x][0] == 'I') {
    return dp[x] = a[x];
  }
  if (a[x]) r = dfs(a[x]);
  if (b[x]) r1 = dfs(b[x]);
  if (s[x][0] == 'N') dp[x] = !r;
  ;
  if (s[x][0] == 'X') dp[x] = r ^ r1;
  if (s[x][0] == 'O') dp[x] = r | r1;
  if (s[x][0] == 'A') dp[x] = r & r1;
  return dp[x];
}
int ch1[1001000];
void ch(int x, bool b1) {
  if (b1 == dp[x]) return;
  if (s[x][0] == 'I') {
    ch1[x] = 1;
    return;
  }
  if (s[x][0] == 'N') {
    ch(a[x], !dp[a[x]]);
  }
  if (s[x][0] == 'X') {
    ch(a[x], !dp[a[x]]);
    ch(b[x], !dp[b[x]]);
  }
  if (s[x][0] == 'O') {
    if (dp[x] == 0) {
      ch(a[x], !dp[a[x]]);
      ch(b[x], !dp[b[x]]);
    } else {
      if (dp[a[x]] == 0 && dp[b[x]] == 1) ch(b[x], !dp[b[x]]);
      if (dp[a[x]] == 1 && dp[b[x]] == 0) ch(a[x], !dp[a[x]]);
    }
  }
  if (s[x][0] == 'A') {
    if (dp[x] == 1) {
      ch(a[x], !dp[a[x]]);
      ch(b[x], !dp[b[x]]);
    } else {
      if (dp[a[x]] == 0 && dp[b[x]] == 1) ch(a[x], !dp[a[x]]);
      if (dp[a[x]] == 1 && dp[b[x]] == 0) ch(b[x], !dp[b[x]]);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s%d", s[i], &a[i]);
    if (s[i][0] == 'I') continue;
    p[i].push_back(a[i]);
    if (s[i][0] == 'N') continue;
    scanf("%d", &b[i]);
    p[i].push_back(b[i]);
  }
  int res = dfs(1);
  ch(1, !res);
  for (int i = 1; i <= n; i++) {
    if (s[i][0] == 'I') {
      printf("%d", (ch1[i] + res) % 2);
    }
  }
  return 0;
}
