#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
template <class T>
int sgn(T x) {
  return (x > 0) - (x < 0);
}
template <typename T>
inline void read(vector<T>& v) {
  for (T& i : v) cin >> i;
}
vi ans;
bool operate(bool a, bool b, int op) {
  if (op == 0) {
    return a && b;
  } else if (op == 1) {
    return a || b;
  } else if (op == 2) {
    return a ^ b;
  } else if (op == 3) {
    return !a;
  }
}
struct Node {
  int type, id;
  Node *left, *right;
  int le, ri;
  bool res;
  bool calc() {
    if (type == 3) {
      res = !left->calc();
    } else if (type != 4) {
      res = operate(left->calc(), right->calc(), type);
    }
    return res;
  }
  void willFlip() {
    if (type == 3) {
      left->willFlip();
    } else if (type == 4) {
      ans[id] = 1;
    } else {
      if (operate(!left->res, right->res, type) != res) {
        left->willFlip();
      }
      if (operate(left->res, !right->res, type) != res) {
        right->willFlip();
      }
    }
  }
};
bool solve(int caseN) {
  int n;
  cin >> n;
  vector<Node*> nodes(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int x, y;
    if (s == "AND") {
      cin >> x >> y;
      nodes[i] = new Node{0, i, NULL, NULL, x, y, false};
    } else if (s == "OR") {
      cin >> x >> y;
      nodes[i] = new Node{1, i, NULL, NULL, x, y, false};
    } else if (s == "XOR") {
      cin >> x >> y;
      nodes[i] = new Node{2, i, NULL, NULL, x, y, false};
    } else if (s == "NOT") {
      cin >> x;
      nodes[i] = new Node{3, i, NULL, NULL, x, 1, false};
    } else {
      cin >> x;
      nodes[i] = new Node{4, i, NULL, NULL, 1, 1, x == 1};
    }
  }
  for (int i = 0; i < n; i++) {
    nodes[i]->left = nodes[nodes[i]->le - 1];
    nodes[i]->right = nodes[nodes[i]->ri - 1];
  }
  ans = vi(n);
  nodes[0]->calc();
  nodes[0]->willFlip();
  for (int i = 0; i < n; i++) {
    if (nodes[i]->type == 4) {
      cout << (ans[i] ^ nodes[0]->res);
    }
  }
  cout << "\n";
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  for (int i = 1; solve(i); i++)
    ;
  cout.flush();
  return 0;
}
