#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000100;
char result[MAX];
int type[MAX];
int leftc[MAX], rightc[MAX], changed[MAX], now[MAX], par[MAX];
int findnow(int node) {
  if (type[node] == 0) {
    return now[node];
  }
  int xn = findnow(leftc[node]);
  if (type[node] == 4) {
    xn = !xn;
    now[node] = xn;
    return xn;
  }
  int yn = findnow(rightc[node]);
  switch (type[node]) {
    case 1:
      now[node] = (xn & yn);
      break;
    case 2:
      now[node] = (xn | yn);
      break;
    case 3:
      now[node] = (xn ^ yn);
      break;
  }
  return now[node];
}
int findchanged(int node, int value) {
  if (node == 1) return value;
  if (value == now[node]) {
    return now[1];
  }
  if (changed[node] >= 0) {
    return changed[node];
  }
  int p = par[node];
  if (type[p] == 4) {
    int x = findchanged(p, !value);
    changed[node] = x;
    return x;
  }
  int lc = leftc[p];
  int rc = rightc[p];
  int xn = now[lc];
  int yn = now[rc];
  if (lc == node) {
    xn = value;
  } else {
    yn = value;
  }
  int tv;
  switch (type[p]) {
    case 1:
      tv = (xn & yn);
      break;
    case 2:
      tv = (xn | yn);
      break;
    case 3:
      tv = (xn ^ yn);
      break;
  }
  int x = findchanged(p, tv);
  changed[node] = x;
  return x;
}
void solve() {
  long long n;
  cin >> n;
  char tt[10];
  for (int i = 1; i <= n; ++i) {
    changed[i] = -1;
    cin >> tt;
    if (tt[0] == 'I') {
      type[i] = 0;
      cin >> now[i];
    } else if (tt[0] == 'N') {
      type[i] = 4;
      cin >> leftc[i];
      par[leftc[i]] = i;
    } else {
      if (tt[0] == 'A') {
        type[i] = 1;
      } else if (tt[0] == 'O') {
        type[i] = 2;
      } else {
        type[i] = 3;
      }
      cin >> leftc[i] >> rightc[i];
      par[leftc[i]] = i;
      par[rightc[i]] = i;
    }
  }
  findnow(1);
  int tot = 0;
  for (int i = 1; i <= n; ++i) {
    if (type[i] == 0) {
      int r = findchanged(i, !now[i]);
      if (r) {
        result[tot] = '1';
      } else {
        result[tot] = '0';
      }
      ++tot;
    }
  }
  result[tot] = 0;
  cout << result;
}
int main() {
  const int inId = 0;
  const int outId = 0;
  if (inId > 0) {
    cerr << "redirect stdin to input " << inId << endl;
    string s = "input";
    s += to_string(inId);
    s += ".txt";
    auto r = freopen(s.c_str(), "r", stdin);
    if (r == nullptr) {
      cerr << "invalid input file " << s;
    }
  }
  if (outId > 0) {
    cerr << "redirect stdout to stdout " << outId << endl;
    string s = "stdout";
    s += to_string(outId);
    s += ".txt";
    auto r = freopen(s.c_str(), "w", stdout);
    if (r == nullptr) {
      cerr << "invalid output file " << s;
    }
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
