#include <bits/stdc++.h>
using namespace std;
int n, l[1000005], p[10000005], val[1000005], res[1 << 20], zgas[1 << 20];
string s[1000005], IN = "IN", XOR = "XOR", AND = "AND", NOT = "NOT", OR = "OR";
void zgar(int v) {
  zgas[v] = 1;
  if (s[v] == IN) return;
  if (!zgas[l[v]]) zgar(l[v]);
  if (s[v] != NOT && !zgas[p[v]]) zgar(p[v]);
}
void dfs(int i) {
  if (s[i] == IN) {
    res[i] = val[i];
    return;
  }
  dfs(l[i]);
  if (s[i] != NOT) dfs(p[i]);
  if (s[i] == AND) res[i] = ((res[l[i]] & res[p[i]]));
  if (s[i] == XOR) res[i] = ((res[l[i]]) ^ (res[p[i]]));
  if (s[i] == NOT) res[i] = !res[l[i]];
  if (s[i] == OR) res[i] = ((res[l[i]]) | (res[p[i]]));
  if (s[i] == AND) {
    if (((!res[l[i]]) & res[p[i]]) == res[i]) zgar(l[i]);
    if ((res[l[i]] & (!res[p[i]])) == res[i]) zgar(p[i]);
  }
  if (s[i] == XOR) {
    if (((!res[l[i]]) ^ (res[p[i]])) == res[i]) zgar(l[i]);
    if ((res[l[i]] ^ (!res[p[i]])) == res[i]) zgar(p[i]);
  }
  if (s[i] == OR) {
    if (((!res[l[i]]) | res[p[i]]) == res[i]) zgar(l[i]);
    if ((res[l[i]] | (!res[p[i]])) == res[i]) zgar(p[i]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i] == IN)
      cin >> val[i];
    else if (s[i] != NOT)
      cin >> l[i] >> p[i];
    else
      cin >> l[i];
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == IN)
      if (zgas[i])
        cout << res[1];
      else
        cout << !res[1];
  }
}
