#include <bits/stdc++.h>
using namespace std;
void openFiles() {}
void IOoptimize() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
struct Node {
  int type;
  int n1 = -1, n2 = -1;
  bool val;
};
const int MAXN = 1e6 + 10;
Node nodes[MAXN];
bool ch[MAXN];
void val_dfs(int u) {
  int n1 = nodes[u].n1;
  int n2 = nodes[u].n2;
  switch (nodes[u].type) {
    case 0: {
      ;
    } break;
    case 1: {
      val_dfs(nodes[u].n1);
      nodes[u].val = !nodes[n1].val;
    } break;
    case 2: {
      val_dfs(nodes[u].n1);
      val_dfs(nodes[u].n2);
      nodes[u].val = (nodes[n1].val && nodes[n2].val);
    } break;
    case 3: {
      val_dfs(nodes[u].n1);
      val_dfs(nodes[u].n2);
      nodes[u].val = (nodes[n1].val || nodes[n2].val);
    } break;
    case 4: {
      val_dfs(nodes[u].n1);
      val_dfs(nodes[u].n2);
      nodes[u].val = (nodes[n1].val ^ nodes[n2].val);
    } break;
  }
}
void dfs(int u) {
  int n1 = nodes[u].n1;
  int n2 = nodes[u].n2;
  switch (nodes[u].type) {
    case 0: {
      ;
    } break;
    case 1: {
      if (ch[u]) ch[n1] = true;
      dfs(nodes[u].n1);
    } break;
    case 2: {
      if (ch[u]) {
        ch[n1] = (!nodes[nodes[u].n1].val && nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val && nodes[nodes[u].n2].val);
        ch[n2] = (nodes[nodes[u].n1].val && !nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val && nodes[nodes[u].n2].val);
      }
      dfs(nodes[u].n1);
      dfs(nodes[u].n2);
    } break;
    case 3: {
      if (ch[u]) {
        ch[n1] = (!nodes[nodes[u].n1].val || nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val || nodes[nodes[u].n2].val);
        ch[n2] = (nodes[nodes[u].n1].val || !nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val || nodes[nodes[u].n2].val);
      }
      dfs(nodes[u].n1);
      dfs(nodes[u].n2);
    } break;
    case 4: {
      if (ch[u]) {
        ch[n1] = (!nodes[nodes[u].n1].val ^ nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val ^ nodes[nodes[u].n2].val);
        ch[n2] = (nodes[nodes[u].n1].val ^ !nodes[nodes[u].n2].val) !=
                 (nodes[nodes[u].n1].val ^ nodes[nodes[u].n2].val);
      }
      dfs(nodes[u].n1);
      dfs(nodes[u].n2);
    } break;
  }
}
int main() {
  openFiles();
  IOoptimize();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    if (str == "IN") {
      nodes[i].type = 0;
      cin >> nodes[i].val;
    }
    if (str == "NOT") {
      nodes[i].type = 1;
      cin >> nodes[i].n1;
    }
    if (str == "AND") {
      nodes[i].type = 2;
      cin >> nodes[i].n1 >> nodes[i].n2;
    }
    if (str == "OR") {
      nodes[i].type = 3;
      cin >> nodes[i].n1 >> nodes[i].n2;
    }
    if (str == "XOR") {
      nodes[i].type = 4;
      cin >> nodes[i].n1 >> nodes[i].n2;
    }
  }
  val_dfs(1);
  ch[1] = true;
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (nodes[i].type == 0) cout << (ch[i] ? 1 - nodes[1].val : nodes[1].val);
  }
  return 0;
}
