#include <bits/stdc++.h>
using namespace std;
vector<long long> AE[1000005];
long long par[1000005];
enum LG { AND = 1, OR = 2, XOR = 3, NOT = 4, IN = 5 };
long long type[1000005], inp[1000005];
inline void nedge(long long a, long long b) { AE[a].push_back(b), par[b] = a; }
bool oans[1000005];
bool dfs(long long p) {
  if (AE[p].size()) {
    volatile bool A = dfs(AE[p][0]), B = AE[p].size() > 1 ? dfs(AE[p][1]) : 0;
    if (type[p] == AND)
      oans[p] = (A and B);
    else if (type[p] == OR)
      oans[p] = (A or B);
    else if (type[p] == XOR)
      oans[p] = (A xor B);
    else if (type[p] == NOT)
      oans[p] = (not A);
  } else
    oans[p] = inp[p];
  return oans[p];
}
bool ans[1000005];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    string x;
    cin >> x;
    long long a, b;
    if (x == "AND") cin >> a >> b, nedge(i, a), nedge(i, b), type[i] = AND;
    if (x == "OR") cin >> a >> b, nedge(i, a), nedge(i, b), type[i] = OR;
    if (x == "XOR") cin >> a >> b, nedge(i, a), nedge(i, b), type[i] = XOR;
    if (x == "NOT") cin >> a, nedge(i, a), type[i] = NOT;
    if (x == "IN") cin >> a, inp[i] = a, type[i] = IN;
  }
  dfs(1);
  queue<long long> q;
  q.push(1);
  while (!q.empty()) {
    long long p = q.front(), pa = par[p];
    q.pop();
    bool nans = 0;
    if (p == 1)
      ans[p] = !oans[p];
    else {
      long long a = AE[pa][0], b = AE[pa].size() > 1 ? AE[pa][1] : -1;
      if (type[pa] == AND)
        nans = ((oans[a] ^ (p == a)) and (oans[b] ^ (p == b)));
      else if (type[pa] == OR)
        nans = ((oans[a] ^ (p == a)) or (oans[b] ^ (p == b)));
      else if (type[pa] == XOR)
        nans = ((oans[a] ^ (p == a)) xor (oans[b] ^ (p == b)));
      else if (type[pa] == NOT)
        nans = (not(oans[a] ^ (p == a)));
      ans[p] = (nans != oans[pa]) ? ans[pa] : oans[1];
    }
    for (long long x : AE[p]) q.push(x);
  }
  for (long long i = 1; i <= n; i++)
    if (type[i] == IN) cout << ans[i];
  cout << '\n';
}
