#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, res[N], to[N][2], ans[N];
char tmpread[10];
pair<char, pair<int, int> > g[N];
vector<pair<int, int> > v[N][2];
vector<int> cur[N][2];
int calc(int node) {
  if (g[node].first == 'I') return res[node] = g[node].second.first;
  if (g[node].first == 'N') return res[node] = !(calc(g[node].second.first));
  if (g[node].first == 'X')
    return res[node] =
               (calc(g[node].second.first) ^ calc(g[node].second.second));
  if (g[node].first == 'O')
    return res[node] =
               (calc(g[node].second.first) | calc(g[node].second.second));
  return res[node] = (calc(g[node].second.first) & calc(g[node].second.second));
}
inline void addto(vector<int> &v, vector<int> &v2) {
  for (int i = 0; i < (int)v2.size(); i++) v.push_back(v2[i]);
}
void calc2(int node) {
  if (g[node].first == 'I') {
    cur[node][g[node].second.first ^ 1].push_back(node);
    return;
  }
  if (g[node].first == 'N') {
    calc2(g[node].second.first);
    swap(cur[node][0], cur[g[node].second.first][1]);
    swap(cur[node][1], cur[g[node].second.first][0]);
    return;
  }
  calc2(g[node].second.first);
  calc2(g[node].second.second);
  int cur1 = res[g[node].second.first];
  int cur2 = res[g[node].second.second];
  if (g[node].first == 'X') {
    if (cur1 == 0) {
      to[g[node].second.second][0] = 0;
      to[g[node].second.second][1] = 1;
    } else {
      to[g[node].second.second][0] = 1;
      to[g[node].second.second][1] = 0;
    }
    if (cur2 == 0) {
      to[g[node].second.first][0] = 0;
      to[g[node].second.first][1] = 1;
    } else {
      to[g[node].second.first][0] = 1;
      to[g[node].second.first][1] = 0;
    }
  } else if (g[node].first == 'O') {
    if (cur1 == 0) {
      to[g[node].second.second][0] = 0;
      to[g[node].second.second][1] = 1;
    } else {
      to[g[node].second.second][0] = 1;
      to[g[node].second.second][1] = 1;
    }
    if (cur2 == 0) {
      to[g[node].second.first][0] = 0;
      to[g[node].second.first][1] = 1;
    } else {
      to[g[node].second.first][0] = 1;
      to[g[node].second.first][1] = 1;
    }
  } else {
    if (cur1 == 0) {
      to[g[node].second.second][0] = 0;
      to[g[node].second.second][1] = 0;
    } else {
      to[g[node].second.second][0] = 0;
      to[g[node].second.second][1] = 1;
    }
    if (cur2 == 0) {
      to[g[node].second.first][0] = 0;
      to[g[node].second.first][1] = 0;
    } else {
      to[g[node].second.first][0] = 0;
      to[g[node].second.first][1] = 1;
    }
  }
  v[node][to[g[node].second.first][0]].push_back(
      make_pair(g[node].second.first, 0));
  v[node][to[g[node].second.first][1]].push_back(
      make_pair(g[node].second.first, 1));
  v[node][to[g[node].second.second][0]].push_back(
      make_pair(g[node].second.second, 0));
  v[node][to[g[node].second.second][1]].push_back(
      make_pair(g[node].second.second, 1));
  for (int i = 0; i < 2; i++) {
    int mx = 0, idx = -1;
    for (int j = 0; j < (int)v[node][i].size(); j++) {
      if ((int)cur[v[node][i][j].first][v[node][i][j].second].size() >= mx) {
        mx = cur[v[node][i][j].first][v[node][i][j].second].size();
        idx = j;
      }
    }
    if (idx == -1) continue;
    swap(cur[node][i], cur[v[node][i][idx].first][v[node][i][idx].second]);
    for (int j = 0; j < (int)v[node][i].size(); j++) {
      if (j == idx) continue;
      addto(cur[node][i], cur[v[node][i][j].first][v[node][i][j].second]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", tmpread);
    g[i].first = tmpread[0];
    if (tmpread[0] == 'I' || tmpread[0] == 'N')
      scanf("%d", &g[i].second.first);
    else
      scanf("%d%d", &g[i].second.first, &g[i].second.second);
  }
  calc(1);
  calc2(1);
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < cur[1][1].size(); i++) {
    ans[cur[1][1][i]] = 1;
  }
  for (int i = 0; i < cur[1][0].size(); i++) {
    ans[cur[1][0][i]] = 0;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] != -1) printf("%d", ans[i]);
  }
  puts("");
  return 0;
}
