#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
int op[maxn], f[maxn], a[maxn], b[maxn], ans[maxn];
int n;
string s;
int getf(int i) {
  if (op[i] == 1)
    f[i] = a[i];
  else if (op[i] == 2)
    f[i] = getf(a[i]) ^ 1;
  else if (op[i] == 3)
    f[i] = getf(a[i]) & getf(b[i]);
  else if (op[i] == 4)
    f[i] = getf(a[i]) | getf(b[i]);
  else if (op[i] == 5)
    f[i] = getf(a[i]) ^ getf(b[i]);
  return f[i];
}
void slove(int i) {
  if (op[i] == 1) {
    ans[i] = 1;
    return;
  } else if (op[i] == 2)
    slove(a[i]);
  else if (op[i] == 3) {
    if (f[a[i]]) slove(b[i]);
    if (f[b[i]]) slove(a[i]);
  } else if (op[i] == 4) {
    if (!f[a[i]]) slove(b[i]);
    if (!f[b[i]]) slove(a[i]);
  } else
    slove(a[i]), slove(b[i]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (s[0] == 'I')
      cin >> a[i], op[i] = 1;
    else if (s[0] == 'N')
      cin >> a[i], op[i] = 2;
    else if (s[0] == 'A')
      cin >> a[i] >> b[i], op[i] = 3;
    else if (s[0] == 'O')
      cin >> a[i] >> b[i], op[i] = 4;
    else if (s[0] == 'X')
      cin >> a[i] >> b[i], op[i] = 5;
  }
  getf(1), slove(1);
  for (int i = 1; i <= n; i++)
    if (op[i] == 1) printf("%d", ans[i] ^ f[1]);
  return 0;
}
