#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
class Tree {
 public:
  int son1, son2;
  int val;
  int op;
  bool rev;
  vector<int> v;
} tree[maxn];
int degree[maxn];
queue<int> q;
void dfs(int id) {
  tree[id].rev = 1;
  if (tree[id].op == 5) return;
  if (tree[id].op == 1) {
    if (tree[tree[id].son1].val) dfs(tree[id].son2);
    if (tree[tree[id].son2].val) dfs(tree[id].son1);
  }
  if (tree[id].op == 2) {
    if (!tree[tree[id].son1].val) dfs(tree[id].son2);
    if (!tree[tree[id].son2].val) dfs(tree[id].son1);
  }
  if (tree[id].op == 3) {
    dfs(tree[id].son1);
    dfs(tree[id].son2);
  }
  if (tree[id].op == 4) {
    dfs(tree[id].son1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    tree[i].rev = 0;
    string s;
    cin >> s;
    if (s == "AND") {
      tree[i].op = 1;
      cin >> tree[i].son1 >> tree[i].son2;
      tree[tree[i].son1].v.push_back(i);
      tree[tree[i].son2].v.push_back(i);
      degree[i] = 2;
    } else if (s == "OR") {
      tree[i].op = 2;
      cin >> tree[i].son1 >> tree[i].son2;
      tree[tree[i].son1].v.push_back(i);
      tree[tree[i].son2].v.push_back(i);
      degree[i] = 2;
    } else if (s == "XOR") {
      tree[i].op = 3;
      cin >> tree[i].son1 >> tree[i].son2;
      tree[tree[i].son1].v.push_back(i);
      tree[tree[i].son2].v.push_back(i);
      degree[i] = 2;
    } else if (s == "NOT") {
      tree[i].op = 4;
      cin >> tree[i].son1;
      tree[tree[i].son1].v.push_back(i);
      degree[i] = 1;
    } else if (s == "IN") {
      tree[i].op = 5;
      cin >> tree[i].val;
      q.push(i);
    }
  }
  int root;
  while (!q.empty()) {
    int id = q.front();
    root = id;
    q.pop();
    for (int i = 0; i < tree[id].v.size(); i++) {
      degree[tree[id].v[i]]--;
      if (!degree[tree[id].v[i]]) q.push(tree[id].v[i]);
    }
    if (tree[id].op == 5)
      continue;
    else if (tree[id].op == 1) {
      tree[id].val = (tree[tree[id].son1].val && tree[tree[id].son2].val);
    } else if (tree[id].op == 2) {
      tree[id].val = (tree[tree[id].son1].val || tree[tree[id].son2].val);
    } else if (tree[id].op == 3) {
      tree[id].val = (tree[tree[id].son1].val ^ tree[tree[id].son2].val);
    } else if (tree[id].op == 4) {
      tree[id].val = !tree[tree[id].son1].val;
    }
  }
  dfs(root);
  for (int i = 1; i <= n; i++)
    if (tree[i].op == 5) {
      if (tree[i].rev)
        cout << !tree[root].val;
      else
        cout << tree[root].val;
    }
  return 0;
}
