#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n;
vector<int> a[N];
int type[N];
bool val[N];
bool f[N];
bool dfs1(int u, int p = -1) {
  if (!type[u]) return val[u];
  vector<int> des;
  for (int v : a[u])
    if (v != p) des.push_back(v);
  if (type[u] == 1) return val[u] = dfs1(des[0], u) & dfs1(des[1], u);
  if (type[u] == 2) return val[u] = dfs1(des[0], u) | dfs1(des[1], u);
  if (type[u] == 3) return val[u] = dfs1(des[0], u) ^ dfs1(des[1], u);
  return val[u] = !dfs1(des[0], u);
}
void dfs2(int u, int p = -1) {
  f[u] = 1;
  if (!type[u]) return;
  vector<int> des;
  for (int v : a[u])
    if (v != p) des.push_back(v);
  if (type[u] == 4)
    dfs2(des[0], u);
  else {
    for (int v : des) {
      int VAL = !val[v];
      for (int k : des)
        if (k != v) {
          if (type[u] == 1)
            VAL &= val[k];
          else if (type[u] == 2)
            VAL |= val[k];
          else
            VAL ^= val[k];
        }
      if (VAL != val[u]) dfs2(v, u);
    }
  }
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string c;
    cin >> c;
    if (c == "IN")
      cin >> val[i];
    else if (c == "NOT") {
      type[i] = 4;
      int x;
      cin >> x;
      a[i].push_back(x);
      a[x].push_back(i);
    } else {
      int x, y;
      cin >> x >> y;
      a[i].push_back(x);
      a[x].push_back(i);
      a[i].push_back(y);
      a[y].push_back(i);
      if (c == "AND")
        type[i] = 1;
      else if (c == "OR")
        type[i] = 2;
      else
        type[i] = 3;
    }
  }
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; ++i)
    if (!type[i]) cout << (f[i] ? !val[1] : val[1]);
  return 0;
}
