#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (!n1) return n2;
  if (!n2) return n1;
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  base %= 1000000007;
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 1000000007;
    base = (base * base) % 1000000007;
    exponent /= 2;
  }
  ans %= 1000000007;
  return ans;
}
string op[1000100 + 1];
vector<int> adj[1000100 + 1];
int cnt[1000100 + 1];
int arr[1000100 + 1];
void dfs(int node) {
  for (int i = 0; i < adj[node].size(); i++) {
    dfs(adj[node][i]);
    cnt[node] += arr[adj[node][i]];
  }
  int sz = adj[node].size();
  if (sz) {
    if (op[node] == "AND") {
      if (cnt[node] == sz)
        arr[node] = 1;
      else
        arr[node] = 0;
    } else if (op[node] == "OR") {
      if (cnt[node])
        arr[node] = 1;
      else
        arr[node] = 0;
    } else if (op[node] == "NOT") {
      arr[node] = 1 - cnt[node];
    } else
      arr[node] = (cnt[node] & 1);
  }
}
bool doesflip[1000100 + 1];
void dfs2(int node) {
  int sz = adj[node].size();
  if (sz == 0) return;
  for (int i = 0; i < sz; i++) {
    int child = adj[node][i];
    if (op[node] == "NOT") {
      doesflip[child] = true;
      dfs2(child);
    } else if (op[node] == "OR") {
      if (arr[node] == 0) {
        doesflip[child] = true;
        dfs2(child);
      } else if (cnt[node] == 1 && arr[child] == 1) {
        doesflip[child] = true;
        dfs2(child);
      }
    } else if (op[node] == "XOR") {
      doesflip[child] = true;
      dfs2(child);
    } else {
      if (arr[node] == 1) {
        doesflip[child] = true;
        dfs2(child);
      } else if (sz == (cnt[node] + 1) && arr[child] == 0) {
        doesflip[child] = true;
        dfs2(child);
      }
    }
  }
}
int main() {
  int n, i, j, k, a, b;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    cin >> op[i];
    if (op[i] == "IN")
      scanf("%d", &arr[i]);
    else {
      if (op[i] == "NOT") {
        scanf("%d", &a);
        adj[i].push_back(a);
      } else {
        scanf("%d", &a);
        scanf("%d", &b);
        adj[i].push_back(a);
        adj[i].push_back(b);
      }
    }
  }
  dfs(1);
  dfs2(1);
  for (i = 1; i <= n; i++)
    if (op[i] == "IN") {
      if (doesflip[i])
        printf("%d", 1 - arr[1]);
      else
        printf("%d", arr[1]);
    }
  return 0;
}
