#include <bits/stdc++.h>
using namespace std;
int __i__, __j__;
class _Debug {
 public:
  template <typename T>
  _Debug& operator,(T val) {
    cout << val << endl;
    return *this;
  }
};
int t[1000000];
vector<int> adjList[1000000];
list<int> output[1000000][2];
int p[1000000];
int size[1000000];
int doDFS(int u) {
  int i;
  int h = -1;
  vector<int> ret;
  size[u] = adjList[u].empty();
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    ret.push_back(doDFS(v));
    size[u] += size[v];
    if ((h == -1) || (size[v] > size[h])) h = v;
  }
  if (h == -1) {
    p[u] = u;
    output[u][!(t[u] - 4)].push_back(u);
    return t[u] - 4;
  } else if (adjList[u].size() == 1) {
    p[u] = p[adjList[u][0]];
    swap(output[p[u]][0], output[p[u]][1]);
    return !ret[0];
  } else {
    p[u] = p[h];
    int other = (h == adjList[u][0]);
    if (t[u] == 0) {
      if (ret[other] == 0)
        output[p[u]][0].splice(output[p[u]][0].end(), output[p[u]][1]);
    } else if (t[u] == 1) {
      if (ret[other] == 1)
        output[p[u]][1].splice(output[p[u]][1].end(), output[p[u]][0]);
    } else if (t[u] == 2) {
      if (ret[other] == 1) swap(output[p[u]][0], output[p[u]][1]);
    }
    int pp = p[adjList[u][other]];
    for (auto it = output[pp][0].begin(); it != output[pp][0].end(); it++) {
      if (t[u] == 0)
        output[p[u]][0].push_back(*it);
      else if (t[u] == 1)
        output[p[u]][ret[!other]].push_back(*it);
      else
        output[p[u]][ret[!other]].push_back(*it);
    }
    for (auto it = output[pp][1].begin(); it != output[pp][1].end(); it++) {
      if (t[u] == 0)
        output[p[u]][ret[!other]].push_back(*it);
      else if (t[u] == 1)
        output[p[u]][1].push_back(*it);
      else
        output[p[u]][!ret[!other]].push_back(*it);
    }
    output[pp][0].clear(), output[pp][1].clear();
    if (t[u] == 0)
      return ret[0] & ret[1];
    else if (t[u] == 1)
      return ret[0] | ret[1];
    else
      return ret[0] ^ ret[1];
  }
}
int main() {
  int i;
  int n;
  char s[4];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      t[i] = 0;
      adjList[i].resize(2);
      scanf("%d %d", &adjList[i][0], &adjList[i][1]);
      adjList[i][0]--, adjList[i][1]--;
    } else if (s[0] == 'O') {
      t[i] = 1;
      adjList[i].resize(2);
      scanf("%d %d", &adjList[i][0], &adjList[i][1]);
      adjList[i][0]--, adjList[i][1]--;
    } else if (s[0] == 'X') {
      t[i] = 2;
      adjList[i].resize(2);
      scanf("%d %d", &adjList[i][0], &adjList[i][1]);
      adjList[i][0]--, adjList[i][1]--;
    } else if (s[0] == 'N') {
      t[i] = 3;
      adjList[i].resize(1);
      scanf("%d", &adjList[i][0]);
      adjList[i][0]--;
    } else {
      scanf("%d", &t[i]);
      t[i] += 4;
    }
  }
  doDFS(0);
  vector<pair<int, int> > ans;
  for (auto it = output[p[0]][0].begin(); it != output[p[0]][0].end(); it++)
    ans.push_back(make_pair(*it, 0));
  for (auto it = output[p[0]][1].begin(); it != output[p[0]][1].end(); it++)
    ans.push_back(make_pair(*it, 1));
  sort(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) printf("%d", ans[i].second);
  printf("\n");
  return 0;
}
