#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
vector<string> op;
vector<vector<int>> in;
vector<bool> natural;
VV<int> a[2];
void add(int t, int v, int r, int u) {
  if (a[t][v].size() < a[r][u].size()) {
    swap(a[t][v], a[r][u]);
  }
  for (int x : a[r][u]) a[t][v].push_back(x);
}
void dfs(int v) {
  if (op[v] == "IN") {
    int val = in[v][0];
    a[val ^ 1][v].push_back(v);
    natural[v] = val;
    return;
  }
  for (int u : in[v]) dfs(u);
  if (op[v] == "NOT") {
    int u = in[v][0];
    add(0, v, 1, u);
    add(1, v, 0, u);
    natural[v] = !natural[u];
    return;
  }
  if (op[v] == "AND") {
    int x = in[v][0], y = in[v][1];
    for (int t = 0; t < (int)(2); t++) {
      if (natural[y] == 0) {
        add(0, v, 0, x);
        add(0, v, 1, x);
      } else {
        add(0, v, 0, x);
        add(1, v, 1, x);
      }
      swap(x, y);
    }
    natural[v] = natural[x] && natural[y];
    return;
  }
  if (op[v] == "OR") {
    int x = in[v][0], y = in[v][1];
    for (int t = 0; t < (int)(2); t++) {
      if (natural[y] == 1) {
        add(1, v, 0, x);
        add(1, v, 1, x);
      } else {
        add(0, v, 0, x);
        add(1, v, 1, x);
      }
      swap(x, y);
    }
    natural[v] = natural[x] || natural[y];
    return;
  }
  if (op[v] == "XOR") {
    int x = in[v][0], y = in[v][1];
    for (int t = 0; t < (int)(2); t++) {
      if (natural[y] == 0) {
        add(0, v, 0, x);
        add(1, v, 1, x);
      } else {
        add(1, v, 0, x);
        add(0, v, 1, x);
      }
      swap(x, y);
    }
    natural[v] = natural[x] ^ natural[y];
    return;
  }
}
int main() {
  int N;
  cin >> N;
  op.resize(N);
  in.resize(N);
  natural.resize(N);
  a[0].resize(N);
  a[1].resize(N);
  for (int i = 0; i < (int)(N); i++) {
    string s;
    cin >> s;
    op[i] = s;
    if (s == "IN" || s == "NOT") {
      int x;
      cin >> x;
      if (s == "NOT") x--;
      in[i].push_back(x);
    } else {
      int x, y;
      cin >> x >> y;
      x--, y--;
      in[i].push_back(x);
      in[i].push_back(y);
    }
  }
  dfs(0);
  using P = pair<int, int>;
  vector<P> ans;
  for (int t = 0; t < (int)(2); t++) {
    for (int v : a[t][0]) ans.push_back(P(v, t));
  }
  sort(ans.begin(), ans.end());
  for (P p : ans) cout << p.second;
  puts("");
}
