#include <bits/stdc++.h>
using namespace std;
int op[1000005];
bool value[1000005];
bool change[1000005];
long req[1000005][2];
bool calc(long i) {
  if (i <= 0) return false;
  value[i] = false;
  if (op[i] == 4) {
    value[i] = (req[i][0] == 1);
  }
  if (op[i] == 3) {
    value[i] = !(calc(req[i][0]));
  }
  if (op[i] == 2) {
    value[i] = (calc(req[i][0]) ^ calc(req[i][1]));
  }
  if (op[i] == 1) {
    value[i] = (calc(req[i][0]) | calc(req[i][1]));
  }
  if (op[i] == 0) {
    value[i] = (calc(req[i][0]) & calc(req[i][1]));
  }
  return value[i];
}
void backTrace(long i, bool vt, bool vf) {
  if (op[i] == 4) {
    if (value[i])
      change[i] = vf;
    else
      change[i] = vt;
  }
  if (op[i] == 3) {
    backTrace(req[i][0], vf, vt);
  }
  if (op[i] == 2) {
    if (value[req[i][1]]) {
      backTrace(req[i][0], vf, vt);
    } else {
      backTrace(req[i][0], vt, vf);
    }
    if (value[req[i][0]]) {
      backTrace(req[i][1], vf, vt);
    } else {
      backTrace(req[i][1], vt, vf);
    }
  }
  if (op[i] == 1) {
    if (value[req[i][1]]) {
      backTrace(req[i][0], vt, vt);
    } else {
      backTrace(req[i][0], vt, vf);
    }
    if (value[req[i][0]]) {
      backTrace(req[i][1], vt, vt);
    } else {
      backTrace(req[i][1], vt, vf);
    }
  }
  if (op[i] == 0) {
    if (value[req[i][1]]) {
      backTrace(req[i][0], vt, vf);
    } else {
      backTrace(req[i][0], vf, vf);
    }
    if (value[req[i][0]]) {
      backTrace(req[i][1], vt, vf);
    } else {
      backTrace(req[i][1], vf, vf);
    }
  }
}
int main() {
  long n;
  cin >> n;
  string s;
  for (long i = 1; i <= n; ++i) {
    cin >> s;
    if (s == "AND") {
      op[i] = 0;
      cin >> req[i][0] >> req[i][1];
    } else if (s == "OR") {
      op[i] = 1;
      cin >> req[i][0] >> req[i][1];
    } else if (s == "XOR") {
      op[i] = 2;
      cin >> req[i][0] >> req[i][1];
    } else if (s == "NOT") {
      op[i] = 3;
      cin >> req[i][0];
    } else {
      op[i] = 4;
      cin >> req[i][0];
    }
  }
  calc(1);
  backTrace(1, true, false);
  for (long i = 1; i <= n; ++i) {
    if (op[i] == 4) {
      if (change[i])
        cout << 1;
      else
        cout << 0;
    }
  }
  cout << endl;
}
