#include <bits/stdc++.h>
using namespace std;
int n;
int p[1000100];
int first[1000100];
vector<pair<int, int> > values;
bool leaf[1000100];
vector<int> edge[1000100];
int lval[1000100];
int val[1000100];
int ans[1000100];
bool solved[1000100][2];
int solveval[1000100][2];
void readinput() {
  cin >> n;
  p[0] = -1;
  for (int i = 0; i < n; i++) {
    string second;
    cin >> second;
    if (second != "IN") {
      if (second == "NOT") {
        int a;
        cin >> a;
        a--;
        p[a] = i;
        edge[i].push_back(a);
        first[i] = 3;
      } else {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        p[a] = i;
        p[b] = i;
        if (second == "AND") {
          first[i] = 0;
        } else if (second == "OR") {
          first[i] = 1;
        } else if (second == "XOR") {
          first[i] = 2;
        }
        edge[i].push_back(a);
        edge[i].push_back(b);
      }
    } else {
      int a;
      cin >> a;
      values.push_back(make_pair(i, a));
      leaf[i] = true;
      lval[i] = a;
    }
  }
}
void cdfs(int node) {
  if (leaf[node]) {
    val[node] = lval[node];
  } else {
    for (int i = 0; i < edge[node].size(); i++) {
      cdfs(edge[node][i]);
    }
    if (first[node] == 0) {
      val[node] = val[edge[node][0]] & val[edge[node][1]];
    } else if (first[node] == 1) {
      val[node] = val[edge[node][0]] | val[edge[node][1]];
    } else if (first[node] == 2) {
      val[node] = val[edge[node][0]] ^ val[edge[node][1]];
    } else if (first[node] == 3) {
      val[node] = !val[edge[node][0]];
    }
  }
}
int dp(int cn, int cv) {
  if (p[cn] == -1) {
    solved[cn][cv] = true;
    solveval[cn][cv] = cv;
    return cv;
  }
  if (solved[cn][cv]) {
    return solveval[cn][cv];
  }
  solved[cn][cv] = true;
  int temp = cv;
  if (first[p[cn]] == 0) {
    if (edge[p[cn]][0] == cn) {
      cv = val[edge[p[cn]][1]] & cv;
    } else {
      cv = val[edge[p[cn]][0]] & cv;
    }
  } else if (first[p[cn]] == 1) {
    if (edge[p[cn]][0] == cn) {
      cv = val[edge[p[cn]][1]] | cv;
    } else {
      cv = val[edge[p[cn]][0]] | cv;
    }
  } else if (first[p[cn]] == 2) {
    if (edge[p[cn]][0] == cn) {
      cv = val[edge[p[cn]][1]] ^ cv;
    } else {
      cv = val[edge[p[cn]][0]] ^ cv;
    }
  } else if (first[p[cn]] == 3) {
    cv = 1 - cv;
  }
  solveval[cn][temp] = dp(p[cn], cv);
  return solveval[cn][temp];
}
void solve() {
  cdfs(0);
  for (int i = 0; i < values.size(); i++) {
    int lf = values[i].first;
    int vl = values[i].second;
    int cv = 1 - vl;
    int cn = lf;
    ans[i] = dp(cn, cv);
  }
}
void printoutput() {
  for (int i = 0; i < values.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
}
int main() {
  readinput();
  solve();
  printoutput();
}
