#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& vec) {
  out << "[";
  for (int x : vec) out << x << ", ";
  out << "]";
  return out;
}
int n;
string node_type[1000001];
bool curr_state[1000001];
int child[1000001][2];
int ancestor[1000001][25];
bool partial[1000001][25][2];
void calc_wth(int v) {
  if (node_type[v] == "IN") {
  } else if (node_type[v] == "NOT") {
    calc_wth(child[v][0]);
    curr_state[v] = not curr_state[child[v][0]];
  } else {
    calc_wth(child[v][0]);
    calc_wth(child[v][1]);
    if (node_type[v] == "AND")
      curr_state[v] = curr_state[child[v][0]] and curr_state[child[v][1]];
    else if (node_type[v] == "OR")
      curr_state[v] = curr_state[child[v][0]] or curr_state[child[v][1]];
    else
      curr_state[v] = curr_state[child[v][0]] xor curr_state[child[v][1]];
  }
}
void calc_partial(int v, int p) {
  if (p == 0) {
    for (int i = 0; i < 25; i++)
      for (int x = 0; x < 2; x++) {
        partial[v][i][x] = x;
        ancestor[v][i] = v;
      }
  } else {
    if (node_type[p] == "NOT") {
      partial[v][0][0] = 1;
      partial[v][0][1] = 0;
    } else {
      bool y = 0;
      int j = 0;
      if (child[p][0] == v) j = 1;
      y = curr_state[child[p][j]];
      if (node_type[p] == "AND")
        for (int x = 0; x < 2; x++) partial[v][0][x] = x and y;
      if (node_type[p] == "OR")
        for (int x = 0; x < 2; x++) partial[v][0][x] = x or y;
      if (node_type[p] == "XOR")
        for (int x = 0; x < 2; x++) partial[v][0][x] = x xor y;
    }
    ancestor[v][0] = p;
    for (int i = 1; i < 25; i++) {
      ancestor[v][i] = ancestor[ancestor[v][i - 1]][i - 1];
      for (int x = 0; x < 2; x++)
        partial[v][i][x] =
            partial[ancestor[v][i - 1]][i - 1][partial[v][i - 1][x]];
    }
  }
  if (node_type[v] == "IN")
    return;
  else if (node_type[v] == "NOT")
    calc_partial(child[v][0], v);
  else {
    calc_partial(child[v][0], v);
    calc_partial(child[v][1], v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    node_type[i] = s;
    if (s == "IN") {
      cin >> curr_state[i];
    } else if (s == "NOT") {
      cin >> child[i][0];
    } else if (s == "AND") {
      cin >> child[i][0] >> child[i][1];
    } else if (s == "OR") {
      cin >> child[i][0] >> child[i][1];
    } else if (s == "XOR") {
      cin >> child[i][0] >> child[i][1];
    }
  }
  calc_wth(1);
  calc_partial(1, 0);
  for (int i = 1; i <= n; i++)
    if (node_type[i] == "IN") {
      cout << partial[i][24][1 - curr_state[i]];
    }
  cout << '\n';
}
