#include <bits/stdc++.h>
using namespace std;
struct Item {
  int l, r, p, v;
  char op;
};
const int N = 1E6 + 10;
int n;
bool vis[N];
int val[N];
int f[N];
Item t[N];
queue<int> q;
stack<int> st;
void dfs() {
  memset(vis, 0, sizeof(bool) * (n + 1));
  st.push(1);
  while (!st.empty()) {
    int x = st.top();
    if (t[x].l == -1) {
      vis[x] = true;
      st.pop();
      continue;
    }
    if (!vis[t[x].l]) {
      st.push(t[x].l);
      continue;
    }
    if (t[x].r == -1) {
      t[x].v = !t[t[x].l].v;
      vis[x] = true;
      st.pop();
      continue;
    }
    if (!vis[t[x].r]) {
      st.push(t[x].r);
      continue;
    }
    int l = t[x].l, r = t[x].r;
    if (t[x].op == 'A')
      t[x].v = t[l].v & t[r].v;
    else if (t[x].op == 'X')
      t[x].v = t[l].v ^ t[r].v;
    else
      t[x].v = t[l].v | t[r].v;
    vis[x] = true;
    st.pop();
  }
}
void dfs2() {
  memset(f, 0, sizeof(int) * (n + 1));
  memset(vis, 0, sizeof(bool) * (n + 1));
  st.push(1);
  while (!st.empty()) {
    int x = st.top();
    if (t[x].l == -1) {
      vis[x] = true;
      st.pop();
      continue;
    }
    if (!vis[t[x].l]) {
      st.push(t[x].l);
      continue;
    }
    if (t[x].r == -1) {
      vis[x] = true;
      f[t[x].l] = x;
      st.pop();
      continue;
    }
    if (!vis[t[x].r]) {
      st.push(t[x].r);
      continue;
    }
    int l = t[x].l, r = t[x].r;
    if (t[x].op == 'X')
      f[l] = f[r] = x;
    else if (t[x].op == 'A') {
      if (t[l].v == 1) f[r] = x;
      if (t[r].v == 1) f[l] = x;
    } else if (t[x].op = 'O') {
      if (t[l].v == 0) f[r] = x;
      if (t[r].v == 0) f[l] = x;
    }
    vis[x] = true;
    st.pop();
  }
}
void gf(int x) {
  int y = x;
  while (f[y] != 0) y = f[y];
  int z = x;
  while (f[z] != 0) {
    int tmp = f[z];
    f[z] = y;
    z = tmp;
  }
}
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) t[i] = Item{-1, -1, -1, -1, '\0'};
    char s[10];
    int x, y;
    for (int i = 1; i <= n; i++) {
      scanf("%s", s);
      if (s[0] == 'I' || s[0] == 'N') {
        scanf("%d", &x);
        if (s[0] == 'I') {
          t[i].v = x;
          t[i].op = 'I';
        } else {
          t[x].p = i;
          t[i].l = x;
          t[i].op = 'N';
        }
      } else {
        scanf("%d %d", &x, &y);
        t[i].l = x, t[i].r = y;
        t[i].op = s[0];
        t[x].p = i, t[y].p = i;
      }
    }
    dfs();
    dfs2();
    for (int i = 1; i <= n; i++) gf(i);
    for (int i = 1; i <= n; i++) {
      if (t[i].l == -1) {
        if (f[i] == 1)
          putchar(t[1].v == 1 ? '0' : '1');
        else
          putchar(t[1].v == 1 ? '1' : '0');
      }
    }
    puts("");
  }
}
