#include <bits/stdc++.h>
using namespace std;
const int maxm = 1e6 + 5;
vector<int> g[maxm];
int ans[maxm];
int d[maxm];
int v[maxm];
int n;
int dfs(int x) {
  if (d[x] == 1)
    return v[x] = dfs(g[x][0]) & dfs(g[x][1]);
  else if (d[x] == 2)
    return v[x] = dfs(g[x][0]) | dfs(g[x][1]);
  else if (d[x] == 3)
    return v[x] = dfs(g[x][0]) ^ dfs(g[x][1]);
  else if (d[x] == 4)
    return v[x] = !dfs(g[x][0]);
  else
    return v[x];
}
void dfs2(int x) {
  if (d[x] == 1) {
    if (v[x] == 1) {
      dfs2(g[x][0]);
      dfs2(g[x][1]);
    } else {
      if (!v[g[x][0]] && v[g[x][1]]) dfs2(g[x][0]);
      if (v[g[x][0]] && !v[g[x][1]]) dfs2(g[x][1]);
    }
  } else if (d[x] == 2) {
    if (v[g[x][0]] && !v[g[x][1]]) dfs2(g[x][0]);
    if (!v[g[x][0]] && v[g[x][1]]) dfs2(g[x][1]);
    if (!v[g[x][0]] && !v[g[x][1]]) {
      dfs2(g[x][0]);
      dfs2(g[x][1]);
    }
  } else if (d[x] == 3) {
    dfs2(g[x][0]);
    dfs2(g[x][1]);
  } else if (d[x] == 4) {
    dfs2(g[x][0]);
  } else if (d[x] == 5) {
    ans[x] = 1;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  string s;
  int l, r;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (s[0] == 'A') {
      d[i] = 1;
      cin >> l >> r;
      g[i].push_back(l);
      g[i].push_back(r);
    } else if (s[0] == 'O') {
      d[i] = 2;
      cin >> l >> r;
      g[i].push_back(l);
      g[i].push_back(r);
    } else if (s[0] == 'X') {
      d[i] = 3;
      cin >> l >> r;
      g[i].push_back(l);
      g[i].push_back(r);
    } else if (s[0] == 'N') {
      d[i] = 4;
      cin >> l;
      g[i].push_back(l);
    } else if (s[0] == 'I') {
      d[i] = 5;
      cin >> v[i];
    }
  }
  dfs(1);
  dfs2(1);
  for (int i = 1; i <= n; i++) {
    if (d[i] == 5) {
      if (ans[i])
        cout << !v[1];
      else
        cout << v[1];
    }
  }
  return 0;
}
