#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int vals[N], A[N], ops[N], n;
vector<int> ss[N][2], g[N];
int oper(int v0, int v1, int op) {
  if (op == 0) return v0 & v1;
  if (op == 1) return v0 | v1;
  return v0 ^ v1;
}
void dfs(int u) {
  if (((int)(g[u]).size()) == 0) {
    vals[u] = A[u];
    return;
  }
  if (((int)(g[u]).size()) == 1) {
    dfs(g[u][0]);
    vals[u] = 1 - vals[g[u][0]];
    return;
  }
  dfs(g[u][0]);
  dfs(g[u][1]);
  vals[u] = oper(vals[g[u][0]], vals[g[u][1]], ops[u]);
}
void solve(int u) {
  if (((int)(g[u]).size()) == 0) {
    ss[u][!A[u]].push_back(u);
    return;
  }
  if (((int)(g[u]).size()) == 1) {
    solve(g[u][0]);
    swap(ss[u][0], ss[g[u][0]][1]);
    swap(ss[u][1], ss[g[u][0]][0]);
    return;
  }
  for (int v : g[u]) {
    int other = g[u][0] ^ g[u][1] ^ v;
    int val = vals[other];
    solve(v);
    for (int i = 0, qwerty = 2; i < qwerty; i++) {
      int t = oper(val, i, ops[u]);
      0;
      if (((int)(ss[u][t]).size()) < ((int)(ss[v][i]).size()))
        swap(ss[u][t], ss[v][i]);
      ss[u][t].insert(ss[u][t].end(), (ss[v][i]).begin(), (ss[v][i]).end());
      ss[v][i].clear();
    }
  }
  0;
}
int ans[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0, qwerty = n; i < qwerty; i++) {
    string s;
    cin >> s;
    if (s == "AND") {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      g[i].push_back(u);
      g[i].push_back(v);
      ops[i] = 0;
    } else if (s == "IN") {
      int v;
      cin >> v;
      A[i] = v;
    } else if (s == "OR") {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      g[i].push_back(u);
      g[i].push_back(v);
      ops[i] = 1;
    } else if (s == "XOR") {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      g[i].push_back(u);
      g[i].push_back(v);
      ops[i] = 2;
    } else if (s == "NOT") {
      int u;
      cin >> u;
      u--;
      g[i].push_back(u);
    }
  }
  dfs(0);
  solve(0);
  for (int v : ss[0][1]) ans[v] = 1;
  vector<int> leafs = ss[0][1];
  leafs.insert(leafs.end(), (ss[0][0]).begin(), (ss[0][0]).end());
  sort((leafs).begin(), (leafs).end());
  for (int v : leafs) cout << ans[v];
  cout << "\n";
}
