#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 1e6 + 7;
int n, tag[MAXN], ch[MAXN][2], initval[MAXN], par[MAXN], f[MAXN][2];
char buf[10];
void initialize(int u) {
  if (ch[u][0]) initialize(ch[u][0]), par[ch[u][0]] = u;
  if (ch[u][1]) initialize(ch[u][1]), par[ch[u][1]] = u;
  if (tag[u] == 0)
    initval[u] = initval[ch[u][0]] & initval[ch[u][1]];
  else if (tag[u] == 1)
    initval[u] = initval[ch[u][0]] | initval[ch[u][1]];
  else if (tag[u] == 2)
    initval[u] = initval[ch[u][0]] ^ initval[ch[u][1]];
  else if (tag[u] == 3)
    initval[u] = !initval[ch[u][0]];
}
void dfs(int u) {
  if (u == 1)
    f[u][0] = 0, f[u][1] = 1;
  else {
    int bit = initval[u];
    f[u][bit] = f[par[u]][initval[par[u]]];
    if (tag[par[u]] == 0)
      f[u][bit ^ 1] =
          f[par[u]][(initval[ch[par[u]][0]] ^ initval[ch[par[u]][1]] ^ bit) &
                    (bit ^ 1)];
    else if (tag[par[u]] == 1)
      f[u][bit ^ 1] =
          f[par[u]][(initval[ch[par[u]][0]] ^ initval[ch[par[u]][1]] ^ bit) |
                    (bit ^ 1)];
    else if (tag[par[u]] == 2)
      f[u][bit ^ 1] =
          f[par[u]][(initval[ch[par[u]][0]] ^ initval[ch[par[u]][1]] ^ bit) ^
                    (bit ^ 1)];
    else if (tag[par[u]] == 3)
      f[u][bit ^ 1] = f[par[u]][bit];
  }
  if (ch[u][0]) dfs(ch[u][0]);
  if (ch[u][1]) dfs(ch[u][1]);
}
int main() {
  ____();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> buf;
    if (buf[0] == 'A')
      cin >> ch[i][0] >> ch[i][1], tag[i] = 0;
    else if (buf[0] == 'O')
      cin >> ch[i][0] >> ch[i][1], tag[i] = 1;
    else if (buf[0] == 'X')
      cin >> ch[i][0] >> ch[i][1], tag[i] = 2;
    else if (buf[0] == 'N')
      cin >> ch[i][0], tag[i] = 3;
    else
      cin >> initval[i], tag[i] = 4;
  }
  initialize(1);
  dfs(1);
  for (int i = 1; i <= n; i++)
    if (tag[i] == 4) cout << f[i][initval[i] ^ 1];
  cout << endl;
  return 0;
}
