#include <bits/stdc++.h>
using namespace std;
enum logel { AND, OR, XOR, NOT, IN };
struct el {
  logel type;
  int left;
  int right;
  bool value;
};
vector<el> v;
bool dfs_calc(int x) {
  switch (v[x].type) {
    case AND:
      v[x].value = (dfs_calc(v[x].left) & dfs_calc(v[x].right));
      break;
    case XOR:
      v[x].value = (dfs_calc(v[x].left) ^ dfs_calc(v[x].right));
      break;
    case OR:
      v[x].value = (dfs_calc(v[x].left) | dfs_calc(v[x].right));
      break;
    case NOT:
      v[x].value = (!dfs_calc(v[x].left));
      break;
  }
  return v[x].value;
}
vector<bool> answer;
void dfs_change(int x, bool will_change) {
  switch (v[x].type) {
    case IN:
      answer[v[x].left] = will_change;
      break;
    case AND:
      if (v[v[x].left].value) {
        dfs_change(v[x].right, will_change);
      } else {
        dfs_change(v[x].right, false);
      }
      if (v[v[x].right].value) {
        dfs_change(v[x].left, will_change);
      } else {
        dfs_change(v[x].left, false);
      }
      break;
    case XOR:
      dfs_change(v[x].right,
                 will_change && (v[x].value !=
                                 (v[v[x].left].value != !v[v[x].right].value)));
      dfs_change(v[x].left,
                 will_change && (v[x].value !=
                                 (v[v[x].right].value != !v[v[x].left].value)));
      break;
    case OR:
      dfs_change(v[x].right,
                 will_change && (v[x].value !=
                                 (v[v[x].left].value || !v[v[x].right].value)));
      dfs_change(v[x].left,
                 will_change && (v[x].value !=
                                 (v[v[x].right].value || !v[v[x].left].value)));
      break;
    case NOT:
      dfs_change(v[x].left, will_change);
      break;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  v.resize(n);
  int en = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (s[0] == 'I') {
      int a;
      cin >> a;
      v[i] = {logel::IN, en++, -1, a == 1};
    } else if (s[0] == 'N') {
      int a;
      cin >> a;
      v[i] = {logel::NOT, a - 1, -1, false};
    } else {
      int a, b;
      cin >> a >> b;
      logel t;
      switch (s[0]) {
        case 'A':
          t = logel::AND;
          break;
        case 'X':
          t = logel::XOR;
          break;
        case 'O':
          t = logel::OR;
          break;
      }
      v[i] = {t, a - 1, b - 1, false};
    }
  }
  answer.resize(en);
  dfs_calc(0);
  dfs_change(0, true);
  for (int i = 0; i < en; ++i) {
    cout << (answer[i] != v[0].value);
  }
  cout << "\n";
}
