#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:836777216")
using namespace std;
char s[10];
int n;
struct node {
  int type;
  int l, r;
  int x;
  int val;
  node(int _x, int _v, int _t, int _l, int _r)
      : x(_x), val(_v), type(_t), l(_l), r(_r){};
  node(){};
};
int GetType(string a) {
  if (a == "AND") {
    return 1;
  }
  if (a == "OR") {
    return 2;
  }
  if (a == "XOR") {
    return 3;
  }
  if (a == "NOT") {
    return 4;
  }
  if (a == "IN") {
    return 0;
  }
}
node nodes[1000005];
int p[1000005];
int orig_values[1000005];
map<pair<int, int>, int> mq;
int dfs(int v, int par = -1) {
  p[v] = par;
  int val_l = -1;
  int val_r = -1;
  if (nodes[v].l != -1) {
    val_l = dfs(nodes[v].l, v);
  }
  if (nodes[v].r != -1) {
    val_r = dfs(nodes[v].r, v);
  }
  if (nodes[v].type == 0) {
    orig_values[v] = nodes[v].val;
    return nodes[v].val;
  }
  if (nodes[v].type == 1) {
    int val = val_l & val_r;
    mq[make_pair(v, val)] = 0;
    orig_values[v] = val;
    return val;
  }
  if (nodes[v].type == 2) {
    int val = val_l | val_r;
    mq[make_pair(v, val)] = 0;
    orig_values[v] = val;
    return val;
  }
  if (nodes[v].type == 3) {
    int val = val_l ^ val_r;
    mq[make_pair(v, val)] = 0;
    orig_values[v] = val;
    return val;
  }
  if (nodes[v].type == 4) {
    int val = 1 - val_l;
    mq[make_pair(v, val)] = 0;
    orig_values[v] = val;
    return val;
  }
}
vector<pair<int, int> > tmp;
int up(int v, int val) {
  int par = p[v];
  if (par == -1) {
    return val;
  }
  int cur_v;
  if (nodes[par].type == 1) {
    if (nodes[par].l == v) {
      cur_v = val & orig_values[nodes[par].r];
    } else {
      cur_v = val & orig_values[nodes[par].l];
    }
  }
  if (nodes[par].type == 2) {
    if (nodes[par].l == v) {
      cur_v = val | orig_values[nodes[par].r];
    } else {
      cur_v = val | orig_values[nodes[par].l];
    }
  }
  if (nodes[par].type == 3) {
    if (nodes[par].l == v) {
      cur_v = val ^ orig_values[nodes[par].r];
    } else {
      cur_v = val ^ orig_values[nodes[par].l];
    }
  }
  if (nodes[par].type == 4) {
    cur_v = 1 - val;
  }
  if (mq.count(make_pair(par, cur_v))) {
    return mq[make_pair(par, cur_v)];
  }
  tmp.push_back(make_pair(par, cur_v));
  return up(par, cur_v);
}
int main(void) {
  scanf("%d", &n);
  vector<int> leaves;
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%s", &s);
    int t = GetType((string)s);
    int l = -1, r = -1;
    int v = -1;
    if (t) {
      if (t == 4) {
        scanf("%d", &l);
        l--;
      } else {
        scanf("%d%d", &l, &r);
        l--, r--;
      }
    } else {
      scanf("%d", &v);
      leaves.push_back(i);
    }
    nodes[i] = node(i, v, t, l, r);
  }
  int v = dfs(0);
  for (map<pair<int, int>, int>::iterator it = mq.begin(); it != mq.end();
       it++) {
    (*it).second = v;
  }
  sort((leaves).begin(), (leaves).end());
  vector<int> ans;
  for (int(i) = 0; (i) < ((int)(leaves).size()); (i)++) {
    tmp.clear();
    int res = up(leaves[i], 1 - nodes[leaves[i]].val);
    for (int(i) = 0; (i) < ((int)(tmp).size()); (i)++) {
      mq[tmp[i]] = res;
    }
    ans.push_back(res);
  }
  for (int(i) = 0; (i) < ((int)(ans).size()); (i)++) {
    printf("%d", ans[i]);
  }
  printf("\n");
}
