#include <bits/stdc++.h>
using namespace std;
struct node {
  bool val;
  char ch;
  int l, r;
  node() { ch = l = r = -1; }
} arr[(int)1e6 + 5];
vector<pair<int, int> > res;
void dfs(int u) {
  if (arr[u].l == -1 && arr[u].r == -1) return;
  if (arr[u].l != -1) dfs(arr[u].l);
  if (arr[u].r != -1) dfs(arr[u].r);
  if (arr[u].ch == 'A')
    arr[u].val = arr[arr[u].l].val & arr[arr[u].r].val;
  else if (arr[u].ch == 'O')
    arr[u].val = arr[arr[u].l].val | arr[arr[u].r].val;
  else if (arr[u].ch == 'X')
    arr[u].val = arr[arr[u].l].val ^ arr[arr[u].r].val;
  else if (arr[u].l != -1)
    arr[u].val = !arr[arr[u].l].val;
  else
    arr[u].val = !arr[arr[u].r].val;
}
void makeRes(int u, bool change) {
  if (arr[u].ch == 'I') {
    if (!change)
      res.push_back(make_pair(u, arr[1].val));
    else
      res.push_back(make_pair(u, arr[1].val ^ 1));
    return;
  }
  if (arr[u].l != -1 && arr[u].r != -1) {
    bool nowL = arr[arr[u].l].val;
    bool nowR = arr[arr[u].r].val;
    if (arr[u].ch == 'A') {
      if (((nowL ^ 1) & nowR) == arr[u].val)
        makeRes(arr[u].l, change & 0);
      else
        makeRes(arr[u].l, change & 1);
      if ((nowL & (nowR ^ 1)) == arr[u].val)
        makeRes(arr[u].r, change & 0);
      else
        makeRes(arr[u].r, change & 1);
    } else if (arr[u].ch == 'O') {
      if (((nowL ^ 1) | nowR) == arr[u].val)
        makeRes(arr[u].l, change & 0);
      else
        makeRes(arr[u].l, change & 1);
      if ((nowL | (nowR ^ 1)) == arr[u].val)
        makeRes(arr[u].r, change & 0);
      else
        makeRes(arr[u].r, change & 1);
    } else if (arr[u].ch == 'X') {
      if (((nowL ^ 1) ^ nowR) == arr[u].val)
        makeRes(arr[u].l, change & 0);
      else
        makeRes(arr[u].l, change & 1);
      if ((nowL ^ (nowR ^ 1)) == arr[u].val)
        makeRes(arr[u].r, change & 0);
      else
        makeRes(arr[u].r, change & 1);
    }
  } else if (arr[u].l != -1) {
    if ((!(arr[arr[u].l].val ^ 1)) == arr[u].val)
      makeRes(arr[u].l, change & 0);
    else
      makeRes(arr[u].l, change & 1);
  } else {
    if ((!(arr[arr[u].r].val ^ 1)) == arr[u].val)
      makeRes(arr[u].r, change & 0);
    else
      makeRes(arr[u].r, change & 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1, leaf, l, r; i <= n; i++) {
    char s[10];
    scanf("%s", s);
    arr[i].ch = s[0];
    if (s[0] == 'I') {
      scanf("%d", &leaf);
      arr[i].val = leaf;
    } else if (s[0] == 'N') {
      scanf("%d", &l);
      arr[i].l = l;
    } else {
      scanf("%d %d", &l, &r);
      arr[i].l = l;
      arr[i].r = r;
    }
  }
  dfs(1);
  makeRes(1, 1);
  sort(res.begin(), res.end());
  for (int i = 0; i < res.size(); i++) printf("%d", res[i].second);
  puts("");
  return 0;
}
