#include <bits/stdc++.h>
using namespace std;
const int N = int(1e6) + 10, mod = int(1e9) + 7;
int n;
char second[6];
int op[N], x[N];
int a[N], b[N];
bool can[N], used[N];
vector<int> g[N];
void dfs(int v) {
  if (op[v]) dfs(a[v]);
  if (op[v] == 1) {
    dfs(b[v]);
    if (x[a[v]] == 1 && x[b[v]] == 1) {
      can[a[v]] = 1;
      can[b[v]] = 1;
    } else if (x[a[v]] == 0 && x[b[v]] == 1) {
      can[a[v]] = 1;
    } else if (x[b[v]] == 0 && x[a[v]] == 1) {
      can[b[v]] = 1;
    }
    x[v] = (x[a[v]] & x[b[v]]);
  } else if (op[v] == 2) {
    dfs(b[v]);
    if (x[a[v]] == 0 && x[b[v]] == 0) {
      can[a[v]] = 1;
      can[b[v]] = 1;
    } else if (x[a[v]] == 1 && x[b[v]] == 0) {
      can[a[v]] = 1;
    } else if (x[b[v]] == 1 && x[a[v]] == 0) {
      can[b[v]] = 1;
    }
    x[v] = (x[a[v]] | x[b[v]]);
  } else if (op[v] == 3) {
    dfs(b[v]);
    x[v] = (x[a[v]] ^ x[b[v]]);
    can[a[v]] = 1;
    can[b[v]] = 1;
  } else if (op[v] == 4) {
    x[v] = 1 - x[a[v]];
    can[a[v]] = 1;
  }
}
void dfs2(int v) {
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (can[to]) {
      dfs2(to);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("\n%s", second);
    if (second[0] == 'A') {
      op[i] = 1;
      scanf("%d%d", &a[i], &b[i]);
      g[i].push_back(a[i]);
      g[i].push_back(b[i]);
    } else if (second[0] == 'O') {
      op[i] = 2;
      scanf("%d%d", &a[i], &b[i]);
      g[i].push_back(a[i]);
      g[i].push_back(b[i]);
    } else if (second[0] == 'X') {
      op[i] = 3;
      scanf("%d%d", &a[i], &b[i]);
      g[i].push_back(a[i]);
      g[i].push_back(b[i]);
    } else if (second[0] == 'N') {
      op[i] = 4;
      scanf("%d", &a[i]);
      g[i].push_back(a[i]);
    } else {
      scanf("%d", &x[i]);
    }
  }
  dfs(1);
  dfs2(1);
  for (int i = 1; i <= n; i++) {
    if (op[i] == 0) {
      if (used[i])
        printf("%d", 1 - x[1]);
      else
        printf("%d", x[1]);
    }
  }
  return 0;
}
