#include <bits/stdc++.h>
using namespace std;
string type[1000100];
vector<int> vec[1000100], g[1000100];
bool z[1000100], z2[1000100], z3[1000100], ans, was[1000100];
int n;
int x, y;
bool dfs(int x) {
  if (type[x][0] == 'I') {
    z[x] = g[x][0];
    return g[x][0];
  }
  if (type[x][0] == 'A') {
    z[x] = (dfs(g[x][0]) & dfs(g[x][1]));
    return z[x];
  }
  if (type[x][0] == 'X') {
    z[x] = (dfs(g[x][0]) ^ dfs(g[x][1]));
    return z[x];
  }
  if (type[x][0] == 'O') {
    z[x] = (dfs(g[x][0]) | dfs(g[x][1]));
    return z[x];
  }
  if (type[x][0] == 'N') {
    z[x] = !dfs(g[x][0]);
    return z[x];
  }
}
bool dfs2(int x, int y = -1) {
  if (type[x][0] == 'I') {
    z2[x] = !z[x];
  }
  if (type[x][0] == 'A') {
    if (y == g[x][0])
      z2[x] = (z2[y] & z[g[x][1]]);
    else
      z2[x] = (z2[y] & z[g[x][0]]);
  }
  if (type[x][0] == 'X') {
    if (y == g[x][0])
      z2[x] = (z2[y] ^ z[g[x][1]]);
    else
      z2[x] = (z2[y] ^ z[g[x][0]]);
  }
  if (type[x][0] == 'O') {
    if (y == g[x][0])
      z2[x] = (z2[y] | z[g[x][1]]);
    else
      z2[x] = (z2[y] | z[g[x][0]]);
  }
  if (type[x][0] == 'N') {
    z2[x] = !z2[y];
  }
  if (z2[x] == z[x]) {
    ans = z[1];
    return z[1];
  }
  if (x == 1) {
    ans = z2[1];
    return z2[1];
  }
  if (was[x] == true) {
    ans = z3[x];
    return z3[x];
  }
  z2[x] = dfs2(vec[x][0], x);
  was[x] = true;
  z3[x] = ans;
  return z3[x];
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> type[i];
    if (type[i][0] == 'A' || type[i][0] == 'O' || type[i][0] == 'X') {
      cin >> x >> y;
      vec[x].push_back(i);
      vec[y].push_back(i);
      g[i].push_back(x);
      g[i].push_back(y);
    }
    if (type[i][0] == 'N') {
      cin >> x;
      vec[x].push_back(i);
      g[i].push_back(x);
    }
    if (type[i][0] == 'I') {
      cin >> x;
      vec[x].push_back(i);
      g[i].push_back(x);
    }
  }
  z[1] = dfs(1);
  for (int i = 1; i <= n; ++i)
    if (type[i][0] == 'I') {
      ans = -1;
      cout << dfs2(i);
    }
  return 0;
}
