#include <bits/stdc++.h>
const int A = 0, X = 1, O = 2, I = 3, N = 4;
using namespace std;
int tp[1000000], n, bt[1000000];
pair<int, int> nt[1000000];
bool izm[1000000];
void DFS(int i) {
  if (tp[i] == A) {
    int x = nt[i].first, y = nt[i].second;
    if (izm[i]) {
      if (((bt[x] ^ 1) & bt[y]) != bt[i])
        izm[x] = 1;
      else
        izm[x] = 0;
      if (((bt[y] ^ 1) & bt[x]) != bt[i])
        izm[y] = 1;
      else
        izm[y] = 0;
      DFS(x);
      DFS(y);
    } else {
      izm[x] = 0;
      izm[y] = 0;
      DFS(x);
      DFS(y);
    }
  } else if (tp[i] == O) {
    int x = nt[i].first, y = nt[i].second;
    if (izm[i]) {
      if (((bt[x] ^ 1) | bt[y]) != bt[i])
        izm[x] = 1;
      else
        izm[x] = 0;
      if (((bt[y] ^ 1) | bt[x]) != bt[i])
        izm[y] = 1;
      else
        izm[y] = 0;
      DFS(x);
      DFS(y);
    } else {
      izm[x] = 0;
      izm[y] = 0;
      DFS(x);
      DFS(y);
    }
  } else if (tp[i] == X) {
    int x = nt[i].first, y = nt[i].second;
    if (izm[i]) {
      if (((bt[x] ^ 1) ^ bt[y]) != bt[i])
        izm[x] = 1;
      else
        izm[x] = 0;
      if (((bt[y] ^ 1) ^ bt[x]) != bt[i])
        izm[y] = 1;
      else
        izm[y] = 0;
      DFS(x);
      DFS(y);
    } else {
      izm[x] = 0;
      izm[y] = 0;
      DFS(x);
      DFS(y);
    }
  } else if (tp[i] == N) {
    int x = nt[i].first;
    izm[x] = izm[i];
    DFS(x);
  }
}
void dfs(int i) {
  if (tp[i] == A) {
    int x = nt[i].first, y = nt[i].second;
    dfs(x);
    dfs(y);
    bt[i] = bt[x] & bt[y];
  } else if (tp[i] == O) {
    int x = nt[i].first, y = nt[i].second;
    dfs(x);
    dfs(y);
    bt[i] = bt[x] | bt[y];
  } else if (tp[i] == X) {
    int x = nt[i].first, y = nt[i].second;
    dfs(x);
    dfs(y);
    bt[i] = bt[x] ^ bt[y];
  } else if (tp[i] == N) {
    int x = nt[i].first;
    dfs(x);
    bt[i] = bt[x] ^ 1;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int x, y;
    cin >> s;
    if (s[0] == 'A') {
      tp[i] = A;
      cin >> x >> y;
      x--;
      y--;
      nt[i].first = x;
      nt[i].second = y;
    } else if (s[0] == 'O') {
      tp[i] = O;
      cin >> x >> y;
      x--;
      y--;
      nt[i].first = x;
      nt[i].second = y;
    } else if (s[0] == 'N') {
      tp[i] = N;
      cin >> x;
      x--;
      nt[i].first = x;
    } else if (s[0] == 'I') {
      tp[i] = I;
      cin >> x;
      bt[i] = x;
    } else {
      tp[i] = X;
      cin >> x >> y;
      x--;
      y--;
      nt[i].first = x;
      nt[i].second = y;
    }
  }
  dfs(0);
  izm[0] = 1;
  DFS(0);
  for (int i = 0; i < n; i++)
    if (tp[i] == I) {
      if (izm[i])
        cout << (bt[0] ^ 1);
      else
        cout << bt[0];
    }
}
