#include <bits/stdc++.h>
using namespace std;
string op[1000005];
int a[2][1000005];
bool c[1000005];
bool p[2][1000005];
bool cal(int i) {
  if (op[i] == "IN") {
    c[i] = a[0][i];
    return c[i];
  }
  bool y, x = cal(a[0][i] - 1);
  if (op[i] == "NOT") {
    c[i] = !x;
  } else {
    y = cal(a[1][i] - 1);
    if (op[i] == "AND") {
      c[i] = x && y;
    }
    if (op[i] == "OR") {
      c[i] = x || y;
    }
    if (op[i] == "XOR") {
      c[i] = x ^ y;
    }
  }
  return c[i];
}
void poss(int i) {
  if (op[i] == "NOT") {
    p[0][a[0][i] - 1] = p[1][i];
    p[1][a[0][i] - 1] = p[0][i];
    if (op[a[0][i] - 1] != "IN") poss(a[0][i] - 1);
    return;
  }
  if (op[i] == "AND") {
    p[0][a[0][i] - 1] = p[0][i];
    p[1][a[0][i] - 1] = p[c[a[1][i] - 1]][i];
    p[0][a[1][i] - 1] = p[0][i];
    p[1][a[1][i] - 1] = p[c[a[0][i] - 1]][i];
  } else if (op[i] == "OR") {
    p[0][a[0][i] - 1] = p[c[a[1][i] - 1]][i];
    p[1][a[0][i] - 1] = p[1][i];
    p[0][a[1][i] - 1] = p[c[a[0][i] - 1]][i];
    p[1][a[1][i] - 1] = p[1][i];
  } else if (op[i] == "XOR") {
    p[0][a[0][i] - 1] = p[c[a[1][i] - 1]][i];
    p[1][a[0][i] - 1] = p[!c[a[1][i] - 1]][i];
    p[0][a[1][i] - 1] = p[c[a[0][i] - 1]][i];
    p[1][a[1][i] - 1] = p[!c[a[0][i] - 1]][i];
  }
  if (op[a[0][i] - 1] != "IN") poss(a[0][i] - 1);
  if (op[a[1][i] - 1] != "IN") poss(a[1][i] - 1);
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> op[i];
    if (op[i] == "NOT" || op[i] == "IN")
      cin >> a[0][i];
    else
      cin >> a[0][i] >> a[1][i];
  }
  cal(0);
  p[0][0] = 0;
  p[1][0] = 1;
  poss(0);
  for (int i = 0; i < n; i++)
    if (op[i] == "IN") cout << p[!a[0][i]][i];
}
