#include <bits/stdc++.h>
using namespace std;
int n, treeroot = 1;
int lft[1000010], rgt[1000010], par[1000010];
short type[1000010];
bool val[1000010];
short gettype(string s) {
  if (s == "AND") {
    return 1;
  }
  if (s == "OR") {
    return 2;
  }
  if (s == "XOR") {
    return 3;
  }
  if (s == "NOT") {
    return 4;
  }
  return 5;
}
bool vis[1000010], canch[1000010];
void valrek(int root) {
  if (type[root] == 5) {
    return;
  }
  if (lft[root]) {
    valrek(lft[root]);
  }
  if (rgt[root]) {
    valrek(rgt[root]);
  }
  if (type[root] == 1) {
    val[root] = val[lft[root]] & val[rgt[root]];
    if (!val[lft[root]] and !val[rgt[root]]) {
      canch[lft[root]] = 1;
      canch[rgt[root]] = 1;
    } else if (val[lft[root]] and !val[rgt[root]]) {
      canch[lft[root]] = 1;
    } else if (!val[lft[root]] and val[rgt[root]]) {
      canch[rgt[root]] = 1;
    }
    return;
  }
  if (type[root] == 2) {
    val[root] = val[lft[root]] | val[rgt[root]];
    if (val[lft[root]]) {
      canch[rgt[root]] = 1;
    }
    if (val[rgt[root]]) {
      canch[lft[root]] = 1;
    }
    return;
  }
  if (type[root] == 3) {
    val[root] = val[lft[root]] ^ val[rgt[root]];
    return;
  }
  if (type[root] == 4) {
    val[root] = val[lft[root]] ^ 1;
    return;
  }
}
void valrek2(int root, bool mater) {
  if (canch[root]) {
    mater = 1;
  }
  canch[root] = mater;
  if (lft[root]) {
    valrek2(lft[root], mater);
  }
  if (rgt[root]) {
    valrek2(rgt[root], mater);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  int t5[n], t5s = 0;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    if (s == "IN") {
      cin >> val[i];
      type[i] = 5;
      t5[t5s] = i;
      ++t5s;
      continue;
    }
    cin >> lft[i];
    par[lft[i]] = i;
    type[i] = gettype(s);
    if (type[i] < 4) {
      cin >> rgt[i];
      par[rgt[i]] = i;
    }
  }
  lft[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] and type[i] == 4) {
      int idx = i;
      bool numnot = 1;
      while (type[lft[idx]] == 4) {
        vis[idx] = 1;
        if (idx == treeroot) {
          treeroot = lft[idx];
        }
        if (lft[par[idx]] == idx) {
          lft[par[idx]] = lft[idx];
          par[lft[idx]] = par[idx];
        } else {
          rgt[par[idx]] = lft[idx];
          par[lft[idx]] = par[idx];
        }
        numnot ^= 1;
        idx = lft[idx];
      }
      vis[idx] = 1;
      if (!numnot) {
        if (idx == treeroot) {
          treeroot = lft[idx];
        }
        if (lft[par[idx]] == idx) {
          lft[par[idx]] = lft[idx];
          par[lft[idx]] = par[idx];
        } else {
          rgt[par[idx]] = lft[idx];
          par[lft[idx]] = par[idx];
        }
      }
    }
  }
  valrek(treeroot);
  valrek2(treeroot, 0);
  for (int i = 0; i < t5s; ++i) {
    if (canch[t5[i]]) {
      cout << val[treeroot];
    } else {
      cout << (val[treeroot] ^ 1);
    }
  }
}
