#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000001];
char gate[1000001];
int vis[1000001];
int val[1000001];
int out[1000001];
int lf[1000001];
int dfs(int u, int p) {
  if (gate[u] == 'I') {
    vis[u] = 1;
    return val[u];
  }
  vector<int> nd;
  if (gate[u] == 'A') {
    for (int i = 0; i < g[u].size(); i++) {
      if (g[u][i] != p) nd.push_back(g[u][i]);
    }
    int k1 = dfs(nd[0], u), k2 = dfs(nd[1], u);
    int res = k1 & k2;
    if (k1 == 0) out[nd[1]] = 1;
    if (k2 == 0) out[nd[0]] = 1;
    val[u] = res;
    return res;
  }
  if (gate[u] == 'O') {
    for (int i = 0; i < g[u].size(); i++) {
      if (g[u][i] != p) nd.push_back(g[u][i]);
    }
    int k1 = dfs(nd[0], u), k2 = dfs(nd[1], u);
    int res = k1 | k2;
    if (k1 == 1) out[nd[1]] = 1;
    if (k2 == 1) out[nd[0]] = 1;
    val[u] = res;
    return res;
  }
  if (gate[u] == 'X') {
    for (int i = 0; i < g[u].size(); i++) {
      if (g[u][i] != p) nd.push_back(g[u][i]);
    }
    int k1 = dfs(nd[0], u), k2 = dfs(nd[1], u);
    int res = k1 ^ k2;
    val[u] = res;
    return res;
  }
  if (gate[u] == 'N') {
    for (int i = 0; i < g[u].size(); i++) {
      if (g[u][i] != p) nd.push_back(g[u][i]);
    }
    int k1 = dfs(nd[0], u);
    int res = k1 ^ 1;
    val[u] = res;
    return res;
  }
}
void dfs1(int u, int p) {
  if (out[u] == 1) return;
  lf[u] = 1;
  for (int j = 0; j < g[u].size(); j++) {
    int i = g[u][j];
    if (lf[i] == 0) dfs1(i, u);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) vis[i] = 0, out[i] = 0, val[i] = -1, lf[i] = 0;
  vector<int> leaf;
  for (int i = 1; i <= n; i++) {
    string s;
    int u, v;
    cin >> s;
    cin >> u;
    char ch = s[0];
    gate[i] = ch;
    if (ch == 'I') {
      val[i] = u;
      leaf.push_back(i);
    } else if (ch == 'N') {
      g[u].push_back(i);
      g[i].push_back(u);
    } else {
      cin >> v;
      g[i].push_back(u);
      g[u].push_back(i);
      g[i].push_back(v);
      g[v].push_back(i);
    }
  }
  int res = dfs(1, -1);
  dfs1(1, -1);
  for (int j = 0; j < leaf.size(); j++) {
    int i = leaf[j];
    if (lf[i] == 1)
      cout << (res ^ 1);
    else
      cout << res;
  }
  return 0;
}
