#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<int> type;
vector<int> val;
vector<int> val1;
vector<int> mark;
vector<int> visited;
void dfs1(int node) {
  if (type[node] == 1) {
    dfs1(graph[node][0]);
    dfs1(graph[node][1]);
    val[node] = val1[node] = val[graph[node][0]] & val[graph[node][1]];
  } else if (type[node] == 2) {
    dfs1(graph[node][0]);
    dfs1(graph[node][1]);
    val[node] = val1[node] = val[graph[node][0]] | val[graph[node][1]];
  } else if (type[node] == 3) {
    dfs1(graph[node][0]);
    dfs1(graph[node][1]);
    val[node] = val1[node] = val[graph[node][0]] ^ val[graph[node][1]];
  } else if (type[node] == 4) {
    dfs1(graph[node][0]);
    val[node] = val1[node] = val[graph[node][0]] ^ 1;
  } else
    return;
}
void dfs2(int node) {
  if (type[node] == 1) {
    dfs2(graph[node][0]);
    int v;
    v = val1[graph[node][0]] & val[graph[node][1]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][0]] = 0;
    dfs2(graph[node][1]);
    v = val1[graph[node][1]] & val[graph[node][0]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][1]] = 0;
  } else if (type[node] == 2) {
    dfs2(graph[node][0]);
    int v;
    v = val1[graph[node][0]] | val[graph[node][1]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][0]] = 0;
    dfs2(graph[node][1]);
    v = val1[graph[node][1]] | val[graph[node][0]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][1]] = 0;
  } else if (type[node] == 3) {
    dfs2(graph[node][0]);
    int v;
    v = val1[graph[node][0]] ^ val[graph[node][1]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][0]] = 0;
    dfs2(graph[node][1]);
    v = val1[graph[node][1]] ^ val[graph[node][0]];
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][1]] = 0;
  } else if (type[node] == 4) {
    dfs2(graph[node][0]);
    int v = val1[graph[node][0]] ^ 1;
    if (v != val[node]) {
      val1[node] = v;
      mark[node] = 1;
    } else
      mark[graph[node][0]] = 0;
  } else {
    val1[node] = val[node] ^ 1;
    mark[node] = 1;
  }
}
void dfs3(int node) {
  visited[node] = 1;
  if (type[node] == 1) {
    if (!visited[graph[node][0]]) dfs3(graph[node][0]);
    if (!visited[graph[node][1]]) dfs3(graph[node][1]);
  } else if (type[node] == 2) {
    if (!visited[graph[node][0]]) dfs3(graph[node][0]);
    if (!visited[graph[node][1]]) dfs3(graph[node][1]);
  } else if (type[node] == 3) {
    if (!visited[graph[node][0]]) dfs3(graph[node][0]);
    if (!visited[graph[node][1]]) dfs3(graph[node][1]);
  } else if (type[node] == 4) {
    if (!visited[graph[node][0]]) dfs3(graph[node][0]);
  } else {
    mark[node] = 0;
  }
}
int main() {
  int n;
  cin >> n;
  graph.resize(n + 1);
  type.resize(n + 1);
  val.resize(n + 1);
  val1.resize(n + 1);
  mark.resize(n + 1);
  visited.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'A') {
      type[i] = 1;
      int u, v;
      cin >> u >> v;
      graph[i].push_back(u);
      graph[i].push_back(v);
    } else if (s[0] == 'O') {
      type[i] = 2;
      int u, v;
      cin >> u >> v;
      graph[i].push_back(u);
      graph[i].push_back(v);
    } else if (s[0] == 'X') {
      type[i] = 3;
      int u, v;
      cin >> u >> v;
      graph[i].push_back(u);
      graph[i].push_back(v);
    } else if (s[0] == 'N') {
      type[i] = 4;
      int u;
      cin >> u;
      graph[i].push_back(u);
    } else {
      type[i] = 5;
      int u;
      cin >> u;
      val[i] = val1[i] = u;
    }
  }
  for (int i = 1; i <= n; i++) mark[i] = visited[i] = 0;
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; i++)
    if (!visited[i] and mark[i] == 0) dfs3(i);
  for (int i = 1; i <= n; i++) {
    if (type[i] == 5 and mark[i])
      cout << val1[1];
    else if (type[i] == 5 and !mark[i])
      cout << val[1];
  }
  cout << '\n';
  return 0;
}
