#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6, t[] = {0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0};
int n, op[N], u[N], v[N];
bool res, w[N];
char s[10];
bool dfs1(int x) {
  return w[x] = !op[x]       ? u[x]
                : op[x] == 1 ? !dfs1(u[x])
                             : t[op[x] - 2 << 2 | dfs1(u[x]) << 1 | dfs1(v[x])];
}
void dfs2(int x) {
  if (!op[x])
    v[x] = 1;
  else if (op[x] == 1)
    dfs2(u[x]);
  else {
    if (op[x] == 3)
      w[u[x]] ^= 1, w[v[x]] ^= 1;
    else if (op[x] == 4)
      w[u[x]] = w[v[x]] = 1;
    if (w[u[x]] && w[v[x]])
      dfs2(u[x]), dfs2(v[x]);
    else if (w[u[x]] || w[v[x]])
      dfs2(w[u[x]] ? v[x] : u[x]);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == 'I' || s[0] == 'N')
      op[i] = s[0] == 'N', scanf("%d", &u[i]);
    else
      op[i] = s[0] == 'A'   ? 2
              : s[0] == 'O' ? 3
                            : 4,
      scanf("%d%d", &u[i], &v[i]);
  }
  res = dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; i++)
    if (!op[i]) putchar((res ^ v[i]) + '0');
  return puts(""), 0;
}
