#include <bits/stdc++.h>
using namespace std;
string s;
long long a, b, c = 1, d, e, f, g, h, i, j, k, n, m, track;
vector<list<long long> > zk(1000001);
vector<tuple<int, int, int, int, int, bool> > sto(1000001);
vector<long long> vec;
void trump(long long x, long long pa = -1, long long he = 0);
void bush(long long x, long long pa = -1);
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    get<5>(sto[i]) = false;
    cin >> s;
    if (s == "AND") {
      cin >> a >> b;
      get<0>(sto[i]) = 1;
      get<2>(sto[i]) = a;
      get<3>(sto[i]) = b;
      zk[i].push_back(a);
      zk[i].push_back(b);
      zk[a].push_back(i);
      zk[b].push_back(i);
      continue;
    }
    if (s == "OR") {
      cin >> a >> b;
      get<0>(sto[i]) = 2;
      get<2>(sto[i]) = a;
      get<3>(sto[i]) = b;
      zk[i].push_back(a);
      zk[i].push_back(b);
      zk[a].push_back(i);
      zk[b].push_back(i);
      continue;
    }
    if (s == "XOR") {
      cin >> a >> b;
      get<0>(sto[i]) = 3;
      get<2>(sto[i]) = a;
      get<3>(sto[i]) = b;
      zk[i].push_back(a);
      zk[i].push_back(b);
      zk[a].push_back(i);
      zk[b].push_back(i);
      continue;
    }
    if (s == "NOT") {
      cin >> a;
      get<0>(sto[i]) = 4;
      get<2>(sto[i]) = a;
      zk[i].push_back(a);
      zk[a].push_back(i);
      continue;
    }
    if (s == "IN") {
      vec.push_back(i);
      cin >> a;
      get<0>(sto[i]) = 5;
      get<1>(sto[i]) = a;
      continue;
    }
  }
  trump(1);
  list<long long> ans;
  long long pre = get<1>(sto[1]);
  for (i = 0; i < vec.size(); i++) {
    d = 0;
    c = 0;
    f = 1;
    bush(vec[i]);
    if (c == 1) ans.push_back(pre);
    if (c == -1) ans.push_back(!pre);
    if (c == 0) ans.push_back(track);
  }
  for (auto it = ans.begin(); it != ans.end(); it++) cout << *it;
  cout << endl;
  return 0;
}
void trump(long long x, long long pa, long long he) {
  get<4>(sto[x]) = he;
  for (auto it = zk[x].begin(); it != zk[x].end(); it++) {
    if (*it == pa) continue;
    trump(*it, x, he + 1);
  }
  if (get<0>(sto[x]) == 1) {
    get<1>(sto[x]) = get<1>(sto[get<2>(sto[x])]) & get<1>(sto[get<3>(sto[x])]);
    return;
  }
  if (get<0>(sto[x]) == 2) {
    get<1>(sto[x]) = get<1>(sto[get<2>(sto[x])]) | get<1>(sto[get<3>(sto[x])]);
    return;
  }
  if (get<0>(sto[x]) == 3) {
    get<1>(sto[x]) = get<1>(sto[get<2>(sto[x])]) ^ get<1>(sto[get<3>(sto[x])]);
    return;
  }
  if (get<0>(sto[x]) == 4) {
    get<1>(sto[x]) = !get<1>(sto[get<2>(sto[x])]);
    return;
  }
}
void bush(long long x, long long pa) {
  if (f == 0) {
    if (d == 1) get<5>(sto[x]) = true;
    return;
  }
  if (get<0>(sto[x]) == 5) {
    track = !get<1>(sto[x]);
  }
  if (get<0>(sto[x]) == 1) {
    if (get<2>(sto[x]) == pa)
      track = track & get<1>(sto[get<3>(sto[x])]);
    else
      track = track & get<1>(sto[get<2>(sto[x])]);
  }
  if (get<0>(sto[x]) == 2) {
    if (get<2>(sto[x]) == pa)
      track = track | get<1>(sto[get<3>(sto[x])]);
    else
      track = track | get<1>(sto[get<2>(sto[x])]);
  }
  if (get<0>(sto[x]) == 3) {
    if (get<2>(sto[x]) == pa)
      track = track ^ get<1>(sto[get<3>(sto[x])]);
    else
      track = track ^ get<1>(sto[get<2>(sto[x])]);
  }
  if (get<0>(sto[x]) == 4) {
    track = !track;
  }
  if (get<1>(sto[x]) == track) c = 1;
  if (get<5>(sto[x]) && (!get<1>(sto[x])) == track) c = -1;
  if (x == 1 || get<1>(sto[x]) == track || c == -1) f = 0;
  if ((x == 1 && c == 0) || c == -1) d = 1;
  if (f == 0) {
    if (d == 1) get<5>(sto[x]) = true;
    return;
  }
  for (auto it = zk[x].begin(); it != zk[x].end(); it++) {
    if (f == 0) {
      if (d == 1) get<5>(sto[x]) = true;
      return;
    }
    if (*it != pa && get<4>(sto[x]) > get<4>(sto[*it])) {
      bush(*it, x);
    }
  }
}
