#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
bool compare(const pair<int long long, int long long> &a,
             const pair<int long long, int long long> &b) {
  return a.second <= b.second;
}
int long long inline power(int long long a, int long long b, int long long p) {
  a %= p;
  int long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return ans;
}
int long long inv(int long long n, int long long p) {
  return power(n, p - 2, p);
}
bool inline isPrime(int long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int long long gcd(int long long a, int long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
struct vertex {
  char tp;
  vector<int long long> in;
  bool val;
  bool change;
};
vector<vertex> adj(1000001);
int long long dfs1(int long long v) {
  if (adj[v].tp == 'A')
    adj[v].val = dfs1(adj[v].in[0]) & dfs1(adj[v].in[1]);
  else if (adj[v].tp == 'O')
    adj[v].val = dfs1(adj[v].in[0]) | dfs1(adj[v].in[1]);
  else if (adj[v].tp == 'X')
    adj[v].val = dfs1(adj[v].in[0]) ^ dfs1(adj[v].in[1]);
  else if (adj[v].tp == 'N')
    adj[v].val = !dfs1(adj[v].in[0]);
  return adj[v].val;
}
void dfs2(int long long v) {
  if (adj[v].change == false) {
    for (int long long i = 0; i < adj[v].in.size(); i++) {
      adj[adj[v].in[i]].change = false;
    }
  } else {
    if (adj[v].tp == 'A') {
      if (adj[v].val == (!adj[adj[v].in[0]].val & adj[adj[v].in[1]].val)) {
        adj[adj[v].in[0]].change = false;
      } else
        adj[adj[v].in[0]].change = true;
      if (adj[v].val == (adj[adj[v].in[0]].val & !adj[adj[v].in[1]].val)) {
        adj[adj[v].in[1]].change = false;
      } else
        adj[adj[v].in[1]].change = true;
    } else if (adj[v].tp == 'O') {
      if (adj[v].val == (!adj[adj[v].in[0]].val | adj[adj[v].in[1]].val)) {
        adj[adj[v].in[0]].change = false;
      } else
        adj[adj[v].in[0]].change = true;
      if (adj[v].val == (adj[adj[v].in[0]].val | !adj[adj[v].in[1]].val)) {
        adj[adj[v].in[1]].change = false;
      } else
        adj[adj[v].in[1]].change = true;
    } else if (adj[v].tp == 'X') {
      if (adj[v].val == (!adj[adj[v].in[0]].val ^ adj[adj[v].in[1]].val)) {
        adj[adj[v].in[0]].change = false;
      } else
        adj[adj[v].in[0]].change = true;
      if (adj[v].val == (adj[adj[v].in[0]].val ^ !adj[adj[v].in[1]].val)) {
        adj[adj[v].in[1]].change = false;
      } else
        adj[adj[v].in[1]].change = true;
    } else if (adj[v].tp == 'N') {
      if (adj[v].val == (!!adj[adj[v].in[0]].val)) {
        adj[adj[v].in[0]].change = false;
      } else
        adj[adj[v].in[0]].change = true;
    }
  }
  for (int long long i = 0; i < adj[v].in.size(); i++) {
    dfs2(adj[v].in[i]);
  }
}
void solve() {
  int long long n, m, i, j, k, l, r;
  cin >> n;
  for (i = 0; i < n; i++) {
    string s;
    cin >> s;
    adj[i].tp = s[0];
    if (s[0] == 'I') {
      cin >> l;
      adj[i].val = l;
    } else if (s[0] == 'N') {
      cin >> l;
      adj[i].in.push_back(l - 1);
    } else {
      cin >> l >> r;
      adj[i].in.push_back(l - 1);
      adj[i].in.push_back(r - 1);
    }
  }
  dfs1(0);
  adj[0].change = true;
  dfs2(0);
  for (i = 0; i < n; i++) {
    if (adj[i].tp == 'I') {
      l = adj[0].val ^ adj[i].change;
      cout << l;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int long long t = 1;
  while (t--) solve();
}
