#include <bits/stdc++.h>
using namespace std;
const int MX = 1000010, inf = 2e9;
int n;
struct gate {
  string type;
  bool val;
  int x, y;
  void scan() {
    cin >> type;
    if (type == "IN")
      cin >> val;
    else if (type == "NOT")
      cin >> x;
    else
      cin >> x >> y;
  }
} P[MX];
vector<int> G[MX], R[MX];
void add_edge(int u, int v) {
  G[u].push_back(v);
  R[v].push_back(u);
}
bool dfs(int v) {
  if (P[v].type == "IN") return P[v].val;
  if (P[v].type == "NOT") {
    P[v].val = !dfs(P[v].x);
    add_edge(P[v].x, v);
  } else {
    bool a = dfs(P[v].x), b = dfs(P[v].y);
    if (P[v].type == "AND") {
      P[v].val = a && b;
      if (a) add_edge(P[v].y, v);
      if (b) add_edge(P[v].x, v);
    }
    if (P[v].type == "OR") {
      P[v].val = a || b;
      if (!a) add_edge(P[v].y, v);
      if (!b) add_edge(P[v].x, v);
    }
    if (P[v].type == "XOR") {
      P[v].val = a ^ b;
      add_edge(P[v].y, v);
      add_edge(P[v].x, v);
    }
  }
  return P[v].val;
}
bool reach[MX];
void solve() {
  queue<int> Q;
  int deg[MX] = {};
  for (int i = 1; i <= n; i++)
    for (int x : R[i]) deg[x]++;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0) Q.push(i);
  reach[1] = true;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (int x : R[v]) {
      reach[x] |= reach[v];
      deg[x]--;
      if (deg[x] == 0) Q.push(x);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) P[i].scan();
  dfs(1);
  solve();
  for (int i = 1; i <= n; i++) {
    if (P[i].type != "IN") continue;
    if (reach[i])
      cout << !P[1].val;
    else
      cout << P[1].val;
  }
  return 0;
}
