#include <bits/stdc++.h>
using namespace std;
int n, i;
vector<int> leaf;
const int N = 2e6 + 5;
string type[N];
vector<vector<int> > v(N);
int changed[N];
int ans[N];
int val[N];
void dfs(int node) {
  if (type[node] == "IN") {
    ans[node] = val[node];
    return;
  }
  if (type[node] == "AND" || type[node] == "OR" || type[node] == "XOR") {
    dfs(v[node][0]);
    dfs(v[node][1]);
    if (type[node] == "AND") {
      ans[node] = ans[v[node][0]] && ans[v[node][1]];
    }
    if (type[node] == "OR") {
      ans[node] = ans[v[node][0]] || ans[v[node][1]];
    }
    if (type[node] == "XOR") {
      ans[node] = ans[v[node][0]] ^ ans[v[node][1]];
    }
  }
  if (type[node] == "NOT") {
    dfs(v[node][0]);
    ans[node] = 1 - ans[v[node][0]];
  }
}
void dfs2(int node) {
  if (type[node] == "IN") {
    changed[node] = 1;
    return;
  }
  if (type[node] == "AND") {
    int val1, val2;
    val1 = ans[v[node][0]];
    val2 = ans[v[node][1]];
    if (val1 == 1 && val2 == 1) {
      dfs2(v[node][0]);
      dfs2(v[node][1]);
      return;
    }
    if (val1 == 0 && val2 == 1) {
      dfs2(v[node][0]);
    }
    if (val1 == 1 && val2 == 0) {
      dfs2(v[node][1]);
    }
  }
  if (type[node] == "OR") {
    int val1, val2;
    val1 = ans[v[node][0]];
    val2 = ans[v[node][1]];
    if (val1 + val2 == 2) return;
    if (val1 + val2 == 0) {
      dfs2(v[node][0]);
      dfs2(v[node][1]);
      return;
    }
    if (val1 == 0 && val2 == 1) {
      dfs2(v[node][1]);
      return;
    }
    if (val1 == 1 && val2 == 0) {
      dfs2(v[node][0]);
      return;
    }
  }
  if (type[node] == "XOR") {
    dfs2(v[node][0]);
    dfs2(v[node][1]);
  }
  if (type[node] == "NOT") {
    dfs2(v[node][0]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    string t;
    cin >> t;
    if (t == "IN") {
      type[i] = t;
      leaf.push_back(i);
      cin >> val[i];
    }
    if (t == "AND" || t == "OR" || t == "XOR") {
      type[i] = t;
      int first, second;
      cin >> first >> second;
      v[i].push_back(first);
      v[i].push_back(second);
    }
    if (t == "NOT") {
      int first;
      type[i] = t;
      cin >> first;
      v[i].push_back(first);
    }
  }
  dfs(1);
  dfs2(1);
  for (auto u : leaf) {
    if (changed[u] == 1)
      cout << 1 - ans[1];
    else
      cout << ans[1];
  }
  return 0;
}
