#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> mp[maxn];
string ope[maxn];
int num[maxn];
int vis[maxn];
int imp[maxn];
int dir[maxn], pp = 0;
int dfs(int k) {
  int op = 0, cnt, ans, mem;
  if (ope[k] == "IN")
    return num[k];
  else if (ope[k] == "AND") {
    cnt = 1, ans = 0, mem = -1;
    for (int i = 0; i < mp[k].size(); i++) {
      int d = mp[k][i];
      int re = dfs(d);
      cnt = (cnt & re);
      if (mem == -1 && re == 0) mem = d;
      if (re == 1) ans++;
    }
    if (ans == mp[k].size() - 1) {
      vis[mem] = 1;
    }
    if (ans == mp[k].size()) {
      for (int i = 0; i < mp[k].size(); i++) {
        int d = mp[k][i];
        vis[d] = 1;
      }
    }
    return cnt;
  } else if (ope[k] == "OR") {
    cnt = 0, ans = 0, mem = -1;
    for (int i = 0; i < mp[k].size(); i++) {
      int d = mp[k][i];
      int re = dfs(d);
      cnt = (cnt | re);
      if (mem == -1 && re == 1) mem = d;
      if (re == 0) ans++;
    }
    if (ans == mp[k].size() - 1) {
      vis[mem] = 1;
    }
    if (ans == mp[k].size()) {
      for (int i = 0; i < mp[k].size(); i++) {
        int d = mp[k][i];
        vis[d] = 1;
      }
    }
    return cnt;
  } else if (ope[k] == "XOR") {
    cnt = 0;
    for (int i = 0; i < mp[k].size(); i++) {
      int d = mp[k][i];
      int re = dfs(d);
      cnt = (cnt ^ re);
      vis[d] = 1;
    }
    return cnt;
  } else if (ope[k] == "NOT") {
    cnt = 0;
    for (int i = 0; i < mp[k].size(); i++) {
      int d = mp[k][i];
      int re = dfs(d);
      cnt = (re ^ 1);
      vis[d] = 1;
    }
    return cnt;
  }
}
void dfs_1(int k) {
  if (ope[k] == "IN") imp[k] = 1;
  for (int i = 0; i < mp[k].size(); i++) {
    int d = mp[k][i];
    if (vis[d] == 1) {
      dfs_1(d);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string ss;
    cin >> ss;
    if (ss == "IN") {
      ope[i] = ss;
      int in;
      cin >> in;
      num[i] = in;
      dir[pp++] = i;
    } else if (ss == "NOT") {
      ope[i] = ss;
      int in;
      cin >> in;
      mp[i].push_back(in);
    } else {
      ope[i] = ss;
      int aa, bb;
      cin >> aa >> bb;
      mp[i].push_back(aa);
      mp[i].push_back(bb);
    }
  }
  int re = dfs(1);
  dfs_1(1);
  for (int i = 0; i < pp; i++) {
    if (imp[dir[i]] == 1) {
      cout << (re ^ 1);
    } else
      cout << re;
  }
}
