#include <bits/stdc++.h>
using namespace std;
const int kn = 1e6 + 5;
int n, top = 0, ans[kn];
int type[kn], res[kn], L[kn];
string s;
string X[] = {"XOR", "OR", "AND", "NOT", "IN"};
vector<int> child[kn];
void DFS(int u) {
  if (type[u] == 4) return;
  if (type[u] == 2) res[u] = 1;
  for (int p : child[u]) {
    DFS(p);
    if (type[u] == 0) res[u] ^= res[p];
    if (type[u] == 1) res[u] |= res[p];
    if (type[u] == 2) res[u] &= res[p];
    if (type[u] == 3) res[u] = (!res[p]);
  }
}
void dfs(int u, bool ohno) {
  if (type[u] == 4) {
    ans[u] = ohno;
    return;
  }
  if (ohno == 0) {
    for (int p : child[u]) dfs(p, 0);
    return;
  }
  if (type[u] == 3) dfs(child[u][0], 1);
  if (type[u] == 0) dfs(child[u][0], 1), dfs(child[u][1], 1);
  if (type[u] == 1 || type[u] == 2) {
    int tmp = child[u][0] + child[u][1];
    for (int p : child[u]) {
      int new_val = (type[u] == 1) ? ((not res[p]) | res[tmp - p])
                                   : ((not res[p]) & res[tmp - p]);
      if (new_val != res[u])
        dfs(p, 1);
      else
        dfs(p, 0);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    int c1, c2;
    cin >> c1;
    for (int j = 0; j < 5; j++) {
      if (s == X[j]) {
        if (j < 3) {
          cin >> c2;
          child[i].push_back(c2);
        }
        if (j < 4)
          child[i].push_back(c1);
        else
          res[i] = c1;
        type[i] = j;
        break;
      }
    }
  }
  DFS(1);
  dfs(1, 1);
  for (int i = 1; i <= n; i++)
    if (type[i] == 4) cout << (ans[i] ^ res[1]);
}
