#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6 + 5;
vector<int> G[MAX_N];
char tp[MAX_N];
bool val[MAX_N], ans[MAX_N];
void dfs1(int now, int par) {
  int nOo = 0;
  for (int nxt : G[now]) {
    if (nxt == par) continue;
    dfs1(nxt, now);
    nOo += val[nxt];
  }
  if (tp[now] == 'I')
    return;
  else if (tp[now] == 'X') {
    if (nOo == 1)
      val[now] = true;
    else
      val[now] = false;
  } else if (tp[now] == 'O') {
    if (nOo >= 1)
      val[now] = true;
    else
      val[now] = false;
  } else if (tp[now] == 'A') {
    if (nOo == 2)
      val[now] = true;
    else
      val[now] = false;
  } else {
    if (nOo == 1)
      val[now] = false;
    else
      val[now] = true;
  }
  return;
}
void dfs2(int now, int par, bool canchange) {
  if (tp[now] == 'I') {
    ans[now] = canchange ^ 1;
    return;
  }
  int nOo = 0;
  for (int nxt : G[now]) {
    if (nxt == par) continue;
    nOo += val[nxt];
  }
  for (int nxt : G[now]) {
    if (nxt == par) continue;
    if (canchange) {
      dfs2(nxt, now, true);
    } else {
      if (tp[now] == 'X') {
        dfs2(nxt, now, false);
      } else if (tp[now] == 'O') {
        if (nOo == 2)
          dfs2(nxt, now, true);
        else if (nOo == 0)
          dfs2(nxt, now, false);
        else {
          if (val[nxt])
            dfs2(nxt, now, false);
          else
            dfs2(nxt, now, true);
        }
      } else if (tp[now] == 'A') {
        if (nOo == 0)
          dfs2(nxt, now, true);
        else if (nOo == 2)
          dfs2(nxt, now, false);
        else {
          if (val[nxt])
            dfs2(nxt, now, true);
          else
            dfs2(nxt, now, false);
        }
      } else {
        dfs2(nxt, now, false);
      }
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string t;
    int a, b;
    cin >> t;
    tp[i] = t[0];
    if (t[0] == 'I') {
      cin >> a;
      val[i] = a;
    } else if (t[0] == 'N') {
      cin >> a;
      G[i].push_back(a);
      G[a].push_back(i);
    } else {
      cin >> a >> b;
      G[i].push_back(a);
      G[i].push_back(b);
      G[a].push_back(i);
      G[b].push_back(i);
    }
  }
  dfs1(1, -1);
  dfs2(1, -1, false);
  for (int i = 1; i <= n; i++) {
    if (tp[i] == 'I') cout << (val[1] ^ (ans[i]));
  }
  cout << endl;
  return 0;
}
