#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
vector<int> p, vinput, val, af;
vector<char> op;
char rec[5];
stack<int> sk;
queue<int> qu;
int main() {
  if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
  int n;
  scanf("%d ", &n);
  val.assign(n + 1, -1);
  p.assign(n + 1, 0);
  op.assign(n + 1, 0);
  af.assign(n + 1, 0);
  adj.assign(n + 1, vector<int>());
  for (int i = 1; i < n + 1; i++) {
    scanf("%s ", rec);
    int u, v;
    if (rec[0] == 'I') {
      scanf("%d ", &u);
      vinput.push_back(i);
      val[i] = u;
      op[i] = 'I';
    } else if (rec[0] == 'N') {
      scanf("%d ", &u);
      p[u] = i;
      adj[i].push_back(u);
      op[i] = 'N';
    } else {
      scanf("%d %d ", &u, &v);
      p[u] = p[v] = i;
      adj[i].push_back(u);
      adj[i].push_back(v);
      op[i] = rec[0];
    }
  }
  sk.push(1);
  while (!sk.empty()) {
    int u = sk.top();
    for (int i = 0; i < adj[u].size(); i++)
      if (val[adj[u][i]] == -1) sk.push(adj[u][i]);
    if (u != sk.top()) continue;
    if (op[u] == 'N') val[u] = 1 - val[adj[u][0]];
    if (op[u] == 'A') val[u] = (val[adj[u][0]] && val[adj[u][1]]);
    if (op[u] == 'O') val[u] = (val[adj[u][0]] || val[adj[u][1]]);
    if (op[u] == 'X') val[u] = (val[adj[u][0]] != val[adj[u][1]]);
    sk.pop();
  }
  qu.push(1);
  while (!qu.empty()) {
    int u = qu.front();
    qu.pop();
    for (int i = 0; i < adj[u].size(); i++) qu.push(adj[u][i]);
    af[u] = u;
    int v = p[u];
    if (op[v] == 'N') {
      af[u] = af[v];
      continue;
    }
    if (op[v] == 'A') {
      if (u == adj[v][0] && val[adj[v][1]]) af[u] = af[v];
      if (u == adj[v][1] && val[adj[v][0]]) af[u] = af[v];
    }
    if (op[v] == 'O') {
      if (u == adj[v][0] && val[adj[v][1]] == 0) af[u] = af[v];
      if (u == adj[v][1] && val[adj[v][0]] == 0) af[u] = af[v];
    }
    if (op[v] == 'X') {
      af[u] = af[v];
      continue;
    }
  }
  for (int i = 0; i < vinput.size(); i++)
    printf("%d", (af[vinput[i]] == 1 ? 1 - val[1] : val[1]));
  return 0;
}
