#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int typ[N], n;
bool unc[N], g[N];
vector<int> e[N];
void dfsg(int x) {
  if (!typ[x]) return;
  if (typ[x] == 4) {
    dfsg(e[x][0]);
    g[x] = !g[e[x][0]];
    return;
  }
  dfsg(e[x][0]);
  dfsg(e[x][1]);
  if (typ[x] == 1) g[x] = g[e[x][0]] & g[e[x][1]];
  if (typ[x] == 2) g[x] = g[e[x][0]] | g[e[x][1]];
  if (typ[x] == 3) g[x] = g[e[x][0]] ^ g[e[x][1]];
}
void dfsu(int x, bool stb = 0) {
  if (!typ[x]) {
    unc[x] = stb;
    return;
  }
  if (typ[x] == 4) {
    dfsu(e[x][0], stb);
    return;
  }
  if (stb) {
    dfsu(e[x][0], stb);
    dfsu(e[x][1], stb);
    return;
  }
  int l = g[e[x][0]], r = g[e[x][1]];
  if ((!l && !r && typ[x] == 1) || (l && r && typ[x] == 2)) stb = 1;
  dfsu(e[x][0], stb || (!l && r && typ[x] == 2) || (l && !r && typ[x] == 1));
  dfsu(e[x][1], stb || (!r && l && typ[x] == 2) || (r && !l && typ[x] == 1));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    string s;
    cin >> s;
    if (s == "IN" || s == "NOT")
      cin >> x;
    else {
      cin >> x >> y;
      e[i].push_back(x);
      e[i].push_back(y);
    }
    if (s == "IN") g[i] = x;
    if (s == "AND") typ[i] = 1;
    if (s == "OR") typ[i] = 2;
    if (s == "XOR") typ[i] = 3;
    if (s == "NOT") {
      typ[i] = 4;
      e[i].push_back(x);
    }
  }
  dfsg(1);
  dfsu(1);
  for (int i = 1; i <= n; ++i)
    if (!typ[i]) cout << (g[1] ^ !unc[i]);
  return 0;
}
