#include <bits/stdc++.h>
using namespace std;
int n;
int c[1000010];
int mp[1000];
int in[1000010];
int fir[1000010];
int ans[1000010];
vector<int> v[1000010];
int calc(int nod) {
  if (c[nod] == 5) return fir[nod] = in[nod];
  if (c[nod] == 4) return fir[nod] = 1 - calc(v[nod][0]);
  int q1 = calc(v[nod][0]);
  int q2 = calc(v[nod][1]);
  if (c[nod] == 3) return fir[nod] = q1 ^ q2;
  if (c[nod] == 2) return fir[nod] = q1 | q2;
  if (c[nod] == 1) return fir[nod] = q1 & q2;
}
void dfs(int nod, int ch) {
  if (c[nod] == 5) {
    ans[nod] = ch;
    return;
  }
  if (c[nod] == 4) {
    dfs(v[nod][0], ch);
    return;
  }
  if (ch == 0) {
    dfs(v[nod][0], 0);
    dfs(v[nod][1], 0);
    return;
  }
  int q1 = fir[v[nod][0]];
  int q2 = fir[v[nod][1]];
  if (c[nod] == 3) {
    if ((q1 ^ (!q2)) == fir[nod]) {
      dfs(v[nod][1], 0);
    } else {
      dfs(v[nod][1], 1);
    }
    if ((q2 ^ (!q1)) == fir[nod]) {
      dfs(v[nod][0], 0);
    } else {
      dfs(v[nod][0], 1);
    }
  }
  if (c[nod] == 2) {
    if ((q1 | (!q2)) == fir[nod]) {
      dfs(v[nod][1], 0);
    } else {
      dfs(v[nod][1], 1);
    }
    if ((q2 | (!q1)) == fir[nod]) {
      dfs(v[nod][0], 0);
    } else {
      dfs(v[nod][0], 1);
    }
  }
  if (c[nod] == 1) {
    if ((q1 & (!q2)) == fir[nod]) {
      dfs(v[nod][1], 0);
    } else {
      dfs(v[nod][1], 1);
    }
    if ((q2 & (!q1)) == fir[nod]) {
      dfs(v[nod][0], 0);
    } else {
      dfs(v[nod][0], 1);
    }
  }
}
int main() {
  memset(ans, -1, sizeof ans);
  mp['A'] = 1;
  mp['O'] = 2;
  mp['X'] = 3;
  mp['N'] = 4;
  mp['I'] = 5;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (s == "IN") {
      int a;
      cin >> a;
      c[i] = 5;
      in[i] = a;
    } else if (s == "NOT") {
      int a;
      cin >> a;
      c[i] = mp['N'];
      v[i].push_back(a);
    } else {
      int a, b;
      cin >> a >> b;
      v[i].push_back(a);
      v[i].push_back(b);
      c[i] = mp[s[0]];
    }
  }
  calc(1);
  dfs(1, 1);
  string s1 = "";
  for (int i = 1; i <= n; i++) {
    if (ans[i] != -1) {
      if (ans[i])
        ans[i] = 1 - fir[1];
      else
        ans[i] = fir[1];
      s1 += char('0' + ans[i]);
    }
  }
  cout << s1 << endl;
  return 0;
}
