#include <bits/stdc++.h>
using namespace std;
const int mn = 1e6 + 5;
int n, m;
int a[mn];
int h[mn];
int fa[mn];
int type[mn];
int son[mn][2];
int svalue[mn][2];
int value[mn];
char s[8];
void init(int x, int depth) {
  h[x] = depth;
  for (int i = 0; i < 2; i++) {
    if (son[x][i]) {
      init(son[x][i], depth + 1);
    }
  }
}
struct node {
  int h, id;
  bool operator<(const node &p) const { return h < p.h; }
};
priority_queue<node> q;
bool inq[mn];
void calc(int x) {
  assert(svalue[x][0] != -1);
  if (type[x] == 0) return;
  if (type[x] == 1) {
    value[x] = svalue[x][0] ^ 1;
  } else if (type[x] == 2) {
    value[x] = svalue[x][0] & svalue[x][1];
  } else if (type[x] == 3) {
    value[x] = svalue[x][0] | svalue[x][1];
  } else if (type[x] == 4) {
    value[x] = svalue[x][0] ^ svalue[x][1];
  }
}
int ans[mn];
void dfs(int x) {
  ans[x] ^= 1;
  if (type[x] == 1) dfs(son[x][0]);
  if (type[x] == 2) {
    if (value[x] == 1) {
      dfs(son[x][0]);
      dfs(son[x][1]);
    } else if (svalue[x][0] == 0 && svalue[x][1] == 1)
      dfs(son[x][0]);
    else if (svalue[x][1] == 0 && svalue[x][0] == 1)
      dfs(son[x][1]);
  }
  if (type[x] == 3) {
    if (value[x] == 0) {
      dfs(son[x][0]);
      dfs(son[x][1]);
    } else if (svalue[x][0] == 0 && svalue[x][1] == 1)
      dfs(son[x][1]);
    else if (svalue[x][1] == 0 && svalue[x][0] == 1)
      dfs(son[x][0]);
  }
  if (type[x] == 4) {
    dfs(son[x][0]);
    dfs(son[x][1]);
  }
}
int main() {
  memset(value, -1, sizeof value);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'I' || s[0] == 'N') {
      int u;
      scanf("%d", &u);
      if (s[0] == 'I')
        type[i] = 0, value[i] = u;
      else
        type[i] = 1, son[i][0] = u, fa[u] = i;
    } else {
      int u, v;
      scanf("%d%d", &u, &v);
      if (s[0] == 'A')
        type[i] = 2;
      else if (s[0] == 'O')
        type[i] = 3;
      else
        type[i] = 4;
      son[i][0] = u;
      fa[u] = i;
      son[i][1] = v;
      fa[v] = i;
    }
  }
  init(1, 1);
  for (int i = 1; i <= n; i++) {
    if (type[i] == 0) q.push(node{h[i], i}), inq[i] = 1;
  }
  while (!q.empty()) {
    node u = q.top();
    q.pop();
    calc(u.id);
    if (u.id == 1) break;
    int id = fa[u.id];
    if (son[id][0] == u.id)
      svalue[id][0] = value[u.id];
    else
      svalue[id][1] = value[u.id];
    if (!inq[id]) q.push(node{h[id], id}), inq[id] = 1;
  }
  for (int i = 1; i <= n; i++) ans[i] = value[1];
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (type[i] == 0) printf("%d", ans[i]);
  }
  return 0;
}
