#include <bits/stdc++.h>
using namespace std;
vector<int> par, val, attr;
vector<pair<int, bool> > res;
vector<vector<int> > graph;
int n;
int calcVal(int in) {
  switch (attr[in]) {
    case 0:
      break;
    case 1:
      val[in] = (calcVal(graph[in][0]) | calcVal(graph[in][1]));
      break;
    case 2:
      val[in] = (calcVal(graph[in][0]) & calcVal(graph[in][1]));
      break;
    case 3:
      val[in] = (calcVal(graph[in][0]) ^ calcVal(graph[in][1]));
      break;
    case 4:
      val[in] = (!calcVal(graph[in][0]));
      break;
  }
  return val[in];
}
void dfs(int in, bool flag) {
  switch (attr[in]) {
    case 0:
      res.push_back(make_pair(in, flag));
      break;
    case 1:
      if (val[graph[in][1]])
        dfs(graph[in][0], true);
      else
        dfs(graph[in][0], flag || false);
      if (val[graph[in][0]])
        dfs(graph[in][1], true);
      else
        dfs(graph[in][1], flag || false);
      break;
    case 2:
      if (!val[graph[in][1]])
        dfs(graph[in][0], true);
      else
        dfs(graph[in][0], flag || false);
      if (!val[graph[in][0]])
        dfs(graph[in][1], true);
      else
        dfs(graph[in][1], flag || false);
      break;
    case 3:
      dfs(graph[in][0], flag || false);
      dfs(graph[in][1], flag || false);
      break;
    case 4:
      dfs(graph[in][0], flag || false);
      break;
  }
}
int main() {
  string s;
  int x, y;
  cin >> n;
  val.resize(n);
  par.resize(n);
  graph.resize(n);
  attr.resize(n);
  par[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AND") {
      cin >> x >> y;
      x--;
      y--;
      attr[i] = 2;
      graph[i].push_back(x);
      graph[i].push_back(y);
      par[x] = i;
      par[y] = i;
    } else if (s == "OR") {
      cin >> x >> y;
      x--;
      y--;
      attr[i] = 1;
      graph[i].push_back(x);
      graph[i].push_back(y);
      par[x] = i;
      par[y] = i;
    } else if (s == "XOR") {
      cin >> x >> y;
      x--;
      y--;
      attr[i] = 3;
      graph[i].push_back(x);
      graph[i].push_back(y);
      par[x] = i;
      par[y] = i;
    } else if (s == "IN") {
      cin >> x;
      attr[i] = 0;
      val[i] = x;
    } else if (s == "NOT") {
      cin >> x;
      x--;
      attr[i] = 4;
      graph[i].push_back(x);
      par[x] = i;
    } else {
      cout << "Invalid Input\n";
    }
  }
  calcVal(0);
  dfs(0, false);
  sort(res.begin(), res.end());
  for (int i = 0; i < res.size(); i++) {
    bool k = res[i].second;
    if (k == false)
      cout << (!val[0]);
    else
      cout << val[0];
  }
  cout << "\n";
  return 0;
}
