#include <bits/stdc++.h>
using namespace std;
struct TreeNode;
TreeNode *T[1000001];
struct TreeNode {
  int ins;
  bool bit;
  TreeNode *lc, *rc;
  int canBeChangedBy;
  int canChangeRoot;
  TreeNode() {
    canBeChangedBy = canChangeRoot = 0;
    bit = 0;
    ins = 1;
    lc = rc = NULL;
  }
  void construct(char *s, int vi) {
    ins = s[0];
    switch (s[0]) {
      case 'N':
        lc = T[vi];
        break;
      case 'I':
        bit = vi;
    }
  }
  void construct(char *s, int l, int r) {
    ins = s[0];
    lc = T[l];
    rc = T[r];
  }
  bool canBeWhoChanged() {
    if (lc) lc->canBeWhoChanged();
    if (rc) rc->canBeWhoChanged();
    if (ins == 'I') {
      canBeChangedBy = 0;
      return 1;
    }
    if (ins == 'A') {
      bit = lc->bit & rc->bit;
      if (bit) {
        canBeChangedBy = 3;
      } else {
        if (lc->bit)
          canBeChangedBy = 2;
        else if (rc->bit)
          canBeChangedBy = 1;
      }
    } else if (ins == 'O') {
      bit = lc->bit | rc->bit;
      if (bit == 0) {
        canBeChangedBy = 3;
      } else {
        if (lc->bit & rc->bit)
          canBeChangedBy = 0;
        else if (lc->bit)
          canBeChangedBy = 1;
        else if (rc->bit)
          canBeChangedBy = 2;
      }
    } else if (ins == 'X') {
      bit = lc->bit ^ rc->bit;
      canBeChangedBy = 3;
    } else {
      bit = !lc->bit;
      canBeChangedBy = 1;
    }
    return 1;
  }
  bool canChangeTheRoot(int can) {
    if (can) {
      switch (canBeChangedBy) {
        case 0:
          canChangeRoot = 1;
          return 1;
        case 1:
          canChangeRoot = lc->canChangeTheRoot(1);
          return canChangeRoot;
        case 2:
          canChangeRoot = rc->canChangeTheRoot(1);
          return canChangeRoot;
        case 3:
          canChangeRoot = lc->canChangeTheRoot(1) | rc->canChangeTheRoot(1);
          return canChangeRoot;
      }
      return 1;
    }
    return 0;
  }
};
void show(int &n) {
  for (int i = 1; i <= n; i++) {
    printf("TreeNode %d:\n  ", i);
    printf("bit=%d  canChangeRoot=%d", T[i]->bit, T[i]->canChangeRoot);
    printf("\n\n");
  }
}
int main() {
  int n;
  scanf("%d", &n);
  char s[10];
  for (int i = 1; i <= n; i++) {
    T[i] = new TreeNode;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    int a;
    scanf("%d", &a);
    if (s[0] == 'N' || s[0] == 'I')
      T[i]->construct(s, a);
    else {
      int b;
      scanf("%d", &b);
      T[i]->construct(s, a, b);
    }
  }
  T[1]->canBeWhoChanged();
  T[1]->canChangeTheRoot(1);
  for (int i = 1; i <= n; i++) {
    if (T[i]->ins == 'I')
      if (T[i]->canChangeRoot)
        printf("%d", !T[1]->bit);
      else
        printf("%d", T[1]->bit);
  }
  printf("\n");
  return 0;
}
