#include <bits/stdc++.h>
using namespace std;
const int desll[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const int maxm = 1e8 + 7;
const double eps = 1e-4;
int m, n, ar[maxn];
char ch[maxn];
int armid[maxn];
struct node {
  int val, num;
  char c;
  node *pre, *l, *r;
  void clear() { l = r = NULL; }
} no[maxn];
int ma, ans = 0;
int newCal(node* u) {
  if (u->c == 'N')
    return 1 - (u->l->val);
  else if (u->c == 'A')
    return u->l->val & u->r->val;
  else if (u->c == 'X')
    return u->l->val ^ u->r->val;
  else if (u->c == 'O')
    return u->l->val | u->r->val;
}
void dfs(node* u, int x) {
  int now = u->val;
  u->val = x;
  if (u->pre == NULL || now == x) {
    ans = no[1].val;
  } else {
    if (armid[u->num] != -1) {
      ans = armid[u->num];
    } else {
      dfs(u->pre, newCal(u->pre));
      armid[u->num] = ans;
    }
  }
  u->val = now;
}
void init(node* u) {
  if (u->c == 'I') return;
  init(u->l);
  if (u->r != NULL) init(u->r);
  if (u->c == 'N')
    u->val = 1 - (u->l->val);
  else if (u->c == 'A')
    u->val = u->l->val & u->r->val;
  else if (u->c == 'X')
    u->val = u->l->val ^ u->r->val;
  else if (u->c == 'O')
    u->val = u->l->val | u->r->val;
}
int main() {
  scanf("%d", &n);
  int x, y;
  no[1].pre = NULL;
  for (int i = 0; i <= n; i++) no[i].clear();
  for (int i = 1; i <= n; i++) {
    scanf("%s", ch);
    scanf("%d", &x);
    if (ch[0] == 'A' || ch[0] == 'O' || ch[0] == 'X') {
      scanf("%d", &y);
      no[i].l = &no[x];
      no[i].r = &no[y];
      no[x].pre = &no[i];
      no[y].pre = &no[i];
      no[i].c = ch[0];
    } else if (ch[0] == 'N') {
      no[i].l = &no[x];
      no[x].pre = &no[i];
      no[i].c = ch[0];
    } else {
      no[i].val = x;
      no[i].c = ch[0];
    }
    no[i].num = i;
  }
  memset(armid, -1, sizeof(armid));
  init(&no[1]);
  int len = 0;
  for (int i = 1; i <= n; i++) {
    ma = 0;
    if (no[i].c == 'I') {
      dfs(&no[i], 1 - no[i].val);
      ar[len++] = ans;
    }
  }
  for (int i = 0; i < len; i++) {
    printf("%d", ar[i]);
  }
  printf("\n");
  return 0;
}
