#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
constexpr int infValue =
    std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template <typename T>
constexpr int maxValue =
    std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;
const int INF = 10000000007;
const long long MOD = 1000000007ll;
const double EPS = 1e-6;
const int MAX = maxValue<int>;
using pr = pair<int, int>;
int n;
int dp[1000011][2], op[1000011], val[1000011];
vector<int> g[1000011];
int par[1000011];
int in[1000011];
int dfs(int v) {
  if (op[v] == 0)
    val[v] = in[v];
  else if (op[v] == 1)
    val[v] = dfs(g[v][0]) & dfs(g[v][1]);
  else if (op[v] == 2)
    val[v] = dfs(g[v][0]) | dfs(g[v][1]);
  else if (op[v] == 3)
    val[v] = dfs(g[v][0]) ^ dfs(g[v][1]);
  else if (op[v] == 4)
    val[v] = !dfs(g[v][0]);
  return val[v];
}
void dfs_find(int v) {
  if (v != 1) {
    int p = par[v];
    if (op[p] == 4)
      dp[v][0] = dp[p][1], dp[v][1] = dp[p][0];
    else {
      int v1 = val[g[p][0] == v ? g[p][1] : g[p][0]];
      if (op[p] == 1)
        dp[v][0] = dp[p][0], dp[v][1] = dp[p][v1];
      else if (op[p] == 2)
        dp[v][0] = dp[p][v1], dp[v][1] = dp[p][1];
      else if (op[p] == 3)
        dp[v][0] = dp[p][v1], dp[v][1] = dp[p][!v1];
    }
  }
  for (const int &ch : g[v]) dfs_find(ch);
}
char sop[10];
int main(void) {
  scanf("%d", &n);
  dp[1][0] = 0, dp[1][1] = 1;
  int a, b;
  for (register int i = 1; i <= (n); ++i) {
    scanf("%s", sop);
    g[i].reserve(2);
    if (!strcmp(sop, "IN"))
      op[i] = 0;
    else if (!strcmp(sop, "AND"))
      op[i] = 1;
    else if (!strcmp(sop, "OR"))
      op[i] = 2;
    else if (!strcmp(sop, "XOR"))
      op[i] = 3;
    else if (!strcmp(sop, "NOT"))
      op[i] = 4;
    if (op[i] == 0)
      scanf("%d", in + i);
    else if (op[i] < 4) {
      scanf("%d %d", &a, &b);
      g[i].push_back(a);
      g[i].push_back(b);
      par[a] = (i);
      par[b] = (i);
    } else {
      scanf("%d", &a);
      g[i].push_back(a);
      par[a] = (i);
    }
  }
  dfs(1), dfs_find(1);
  for (register int i = 1; i <= (n); ++i)
    if (!op[i]) printf("%d", dp[i][!in[i]]);
  putc('\n', stdout);
  return 0;
}
