#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 2e6 + 10;
int n;
int ch[N][2];
int node[N], lazy[N], val[N];
int ans[N];
inline int get(char str[]) {
  if (str[0] == 'I') return 1;
  if (str[0] == 'N') return 2;
  if (str[0] == 'O') return 3;
  if (str[0] == 'A') return 4;
  if (str[0] == 'X') return 5;
}
int dfs(int u) {
  if (node[u] == 1) return val[u];
  if (node[u] == 2) {
    return val[u] = (!dfs(ch[u][0]));
  }
  if (node[u] == 3) {
    return val[u] = ((dfs(ch[u][0]) | dfs(ch[u][1])));
  }
  if (node[u] == 4) {
    return val[u] = ((dfs(ch[u][0]) & dfs(ch[u][1])));
  }
  if (node[u] == 5) {
    return val[u] = ((dfs(ch[u][0]) ^ dfs(ch[u][1])));
  }
}
void dfs2(int u) {
  if (lazy[u]) {
    switch (node[u]) {
      case 2:
        lazy[ch[u][0]] = true;
        break;
      case 3:
        if (val[ch[u][0]])
          lazy[ch[u][1]] = false;
        else
          lazy[ch[u][1]] = true;
        if (val[ch[u][1]])
          lazy[ch[u][0]] = false;
        else
          lazy[ch[u][0]] = true;
        break;
      case 4:
        if (!val[ch[u][0]])
          lazy[ch[u][1]] = false;
        else
          lazy[ch[u][1]] = true;
        if (!val[ch[u][1]])
          lazy[ch[u][0]] = false;
        else
          lazy[ch[u][0]] = true;
        break;
      case 5:
        lazy[ch[u][0]] = lazy[ch[u][1]] = true;
        break;
    }
  }
  if (lazy[ch[u][0]] && ch[u][0]) dfs2(ch[u][0]);
  if (lazy[ch[u][1]] && ch[u][1]) dfs2(ch[u][1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char op[10];
    scanf("%s", op);
    node[i] = get(op);
    if (node[i] == 1) {
      scanf("%d", &val[i]);
    } else if (node[i] == 2) {
      int x, y;
      scanf("%d", &x);
      ch[i][0] = x;
    } else {
      int x, y;
      scanf("%d%d", &x, &y);
      ch[i][0] = x;
      ch[i][1] = y;
    }
  }
  dfs(1);
  lazy[1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; i++) {
    if (node[i] == 1) {
      printf("%d", lazy[i] ^ val[1]);
    }
  }
  puts("");
}
