#include <bits/stdc++.h>
using namespace std;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int n;
string op[1000000];
int lchild[1000000], rchild[1000000];
int in[1000000];
int parent[1000000];
vector<int> leafs;
int memo[1000000];
int calc(int x) {
  if (op[x][0] == 'I')
    return in[x];
  else if (op[x][0] == 'A')
    return in[x] = calc(lchild[x]) & calc(rchild[x]);
  else if (op[x][0] == 'O')
    return in[x] = calc(lchild[x]) | calc(rchild[x]);
  else if (op[x][0] == 'X')
    return in[x] = calc(lchild[x]) ^ calc(rchild[x]);
  else
    return in[x] = 1 - calc(lchild[x]);
}
int doit(int x) {
  if (memo[x] >= 0) return memo[x];
  int p = parent[x];
  if (op[p][0] == 'A') {
    int y = lchild[p] == x ? rchild[p] : lchild[p];
    if (in[p] == ((1 - in[x]) & in[y]))
      return memo[x] = in[0];
    else
      return memo[x] = doit(p);
  } else if (op[p][0] == 'O') {
    int y = lchild[p] == x ? rchild[p] : lchild[p];
    if (in[p] == ((1 - in[x]) | in[y]))
      return memo[x] = in[0];
    else
      return memo[x] = doit(p);
  } else if (op[p][0] == 'X') {
    int y = lchild[p] == x ? rchild[p] : lchild[p];
    if (in[p] == ((1 - in[x]) ^ in[y]))
      return memo[x] = in[0];
    else
      return memo[x] = doit(p);
  } else {
    return memo[x] = doit(p);
  }
}
int main() {
  io();
  cin >> n;
  fill(memo, memo + n, -1);
  for (int i = 0; i < n; i++) {
    cin >> op[i];
    if (op[i][0] == 'I') {
      cin >> in[i];
      leafs.push_back(i);
    } else if (op[i][0] == 'N') {
      cin >> lchild[i];
      lchild[i]--;
      parent[lchild[i]] = i;
    } else {
      cin >> lchild[i] >> rchild[i];
      lchild[i]--;
      rchild[i]--;
      parent[lchild[i]] = i;
      parent[rchild[i]] = i;
    }
  }
  calc(0);
  memo[0] = 1 - in[0];
  for (int leaf : leafs) {
    cout << doit(leaf);
  }
  cout << endl;
  return 0;
}
