#include <bits/stdc++.h>
using namespace std;
int p[1000042];
int l[1000042];
int r[1000042];
string type[1000042];
int val[1000042];
bool changes[1000042];
void ev(int i) {
  if (type[i] == "NOT") {
    ev(l[i]);
    val[i] = 1 - val[l[i]];
  }
  if (type[i] == "AND") {
    ev(l[i]);
    ev(r[i]);
    val[i] = val[l[i]] & val[r[i]];
  }
  if (type[i] == "OR") {
    ev(l[i]);
    ev(r[i]);
    val[i] = val[l[i]] | val[r[i]];
  }
  if (type[i] == "XOR") {
    ev(l[i]);
    ev(r[i]);
    val[i] = val[l[i]] ^ val[r[i]];
  }
}
void ch(int i) {
  if (!changes[p[i]]) {
    changes[i] = false;
  } else {
    if (type[p[i]] == "NOT")
      changes[i] = true;
    else {
      if (type[p[i]] == "AND") {
        val[i] = 1 - val[i];
        if (i == l[p[i]]) {
          if (val[p[i]] != (val[i] & val[r[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        } else {
          if (val[p[i]] != (val[i] & val[l[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        }
        val[i] = 1 - val[i];
      }
      if (type[p[i]] == "OR") {
        val[i] = 1 - val[i];
        if (i == l[p[i]]) {
          if (val[p[i]] != (val[i] || val[r[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        } else {
          if (val[p[i]] != (val[i] || val[l[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        }
        val[i] = 1 - val[i];
      }
      if (type[p[i]] == "XOR") {
        val[i] = 1 - val[i];
        if (i == l[p[i]]) {
          if (val[p[i]] != (val[i] ^ val[r[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        } else {
          if (val[p[i]] != (val[i] ^ val[l[p[i]]]))
            changes[i] = true;
          else
            changes[i] = false;
        }
        val[i] = 1 - val[i];
      }
    }
  }
  if (type[i] != "IN") ch(l[i]);
  if (type[i] != "IN" and type[i] != "NOT") ch(r[i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    string act;
    cin >> act;
    type[i] = act;
    if (act == "IN") {
      cin >> val[i];
    } else {
      if (act == "NOT") {
        cin >> x;
        p[x] = i;
        l[i] = x;
      } else {
        cin >> x >> y;
        p[x] = i;
        l[i] = x;
        p[y] = i;
        r[i] = y;
      }
    }
  }
  ev(1);
  p[1] = 0;
  changes[0] = true;
  type[0] = "NOT";
  ch(1);
  string ans = "";
  for (int i = 1; i <= n; i++) {
    if (type[i] != "IN") continue;
    if (changes[i])
      ans += (val[1]) ? '0' : '1';
    else
      ans += (val[1]) ? '1' : '0';
  }
  cout << ans;
}
