#include <bits/stdc++.h>
using namespace std;
int n, m, ans, res, temp, t1, t2, t3, ok, x[1000009][5], val[1000009],
    dp[1000009];
string str;
char ch;
void calc(long long ve) {
  if (x[ve][0] == 0) {
    calc(x[ve][1]);
    calc(x[ve][2]);
    val[ve] = (val[x[ve][1]] & val[x[ve][2]]);
  }
  if (x[ve][0] == 1) {
    calc(x[ve][1]);
    calc(x[ve][2]);
    val[ve] = (val[x[ve][1]] | val[x[ve][2]]);
  }
  if (x[ve][0] == 2) {
    calc(x[ve][1]);
    calc(x[ve][2]);
    val[ve] = (val[x[ve][1]] ^ val[x[ve][2]]);
  }
  if (x[ve][0] == 3) {
    calc(x[ve][1]);
    val[ve] = !(val[x[ve][1]]);
  }
  return;
}
void dpp(long long ve) {
  dp[ve] = 1;
  if (x[ve][0] == 0) {
    if (((val[x[ve][1]] ^ 1) & val[x[ve][2]]) != val[ve]) dpp(x[ve][1]);
    if (((val[x[ve][2]] ^ 1) & val[x[ve][1]]) != val[ve]) dpp(x[ve][2]);
  }
  if (x[ve][0] == 1) {
    if (((val[x[ve][1]] ^ 1) | val[x[ve][2]]) != val[ve]) dpp(x[ve][1]);
    if (((val[x[ve][2]] ^ 1) | val[x[ve][1]]) != val[ve]) dpp(x[ve][2]);
  }
  if (x[ve][0] == 2) {
    if (((val[x[ve][1]] ^ 1) ^ val[x[ve][2]]) != val[ve]) dpp(x[ve][1]);
    if (((val[x[ve][2]] ^ 1) ^ val[x[ve][1]]) != val[ve]) dpp(x[ve][2]);
  }
  if (x[ve][0] == 3) dpp(x[ve][1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> str;
    if (str[0] == 'A') {
      x[i][0] = 0;
      cin >> t1 >> t2;
      x[i][1] = t1;
      x[i][2] = t2;
    }
    if (str[0] == 'O') {
      x[i][0] = 1;
      cin >> t1 >> t2;
      x[i][1] = t1;
      x[i][2] = t2;
    }
    if (str[0] == 'X') {
      x[i][0] = 2;
      cin >> t1 >> t2;
      x[i][1] = t1;
      x[i][2] = t2;
    }
    if (str[0] == 'N') {
      x[i][0] = 3;
      cin >> t1;
      x[i][1] = t1;
    }
    if (str[0] == 'I') {
      x[i][0] = 4;
      cin >> t1;
      val[i] = t1;
    }
  }
  calc(1);
  dpp(1);
  for (long long i = 1; i <= n; i++) {
    if (x[i][0] == 4) cout << ((dp[i]) ^ (val[1]));
  }
}
