#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int v[N][3], cnt[N], tag[N], influ[N];
void dfs(int now) {
  if (tag[now] == 1)
    return;
  else {
    for (int i = 1; i <= cnt[now]; i++) {
      dfs(v[now][i]);
    }
  }
  switch (tag[now]) {
    case 2: {
      v[now][0] = v[v[now][1]][0] & v[v[now][2]][0];
      if (!v[v[now][1]][0]) influ[v[now][2]] = 1;
      if (!v[v[now][2]][0]) influ[v[now][1]] = 1;
      break;
    }
    case 3: {
      v[now][0] = v[v[now][1]][0] | v[v[now][2]][0];
      if (v[v[now][1]][0]) influ[v[now][2]] = 1;
      if (v[v[now][2]][0]) influ[v[now][1]] = 1;
      break;
    }
    case 4: {
      v[now][0] = v[v[now][1]][0] ^ v[v[now][2]][0];
      break;
    }
    case 5: {
      v[now][0] = !v[v[now][1]][0];
      break;
    }
  }
  return;
}
void dfs_2(int now, int fa) {
  influ[now] |= influ[fa];
  if (tag[now] != 1)
    for (int i = 1; i <= cnt[now]; i++) dfs_2(v[now][i], now);
  return;
}
int main() {
  int n;
  string ope;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ope;
    switch (ope[0]) {
      case 'I': {
        scanf("%d", &v[i][0]);
        tag[i] = 1;
        cnt[i] = 1;
        break;
      }
      case 'A': {
        scanf("%d", &v[i][1]);
        scanf("%d", &v[i][2]);
        tag[i] = 2;
        cnt[i] = 2;
        break;
      }
      case 'O': {
        scanf("%d", &v[i][1]);
        scanf("%d", &v[i][2]);
        tag[i] = 3;
        cnt[i] = 2;
        break;
      }
      case 'X': {
        scanf("%d", &v[i][1]);
        scanf("%d", &v[i][2]);
        tag[i] = 4;
        cnt[i] = 2;
        break;
      }
      case 'N': {
        scanf("%d", &v[i][1]);
        tag[i] = 5;
        cnt[i] = 1;
        break;
      }
    }
  }
  dfs(1);
  dfs_2(1, 0);
  for (int i = 1; i <= n; i++) {
    if (tag[i] == 1) {
      if (influ[i])
        printf("%d", v[1][0]);
      else
        printf("%d", 1 - v[1][0]);
    }
  }
}
