#include <bits/stdc++.h>
using namespace std;
template <class T>
void test(T a) {
  cout << a << endl;
}
template <class T, class T2>
void test(T a, T2 b) {
  cout << a << " " << b << endl;
}
template <class T, class T2, class T3>
void test(T a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << endl;
}
int T;
void testcase() { printf("Case #%d:\n", ++T); }
const int N = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
int val[N];
int ch[N][2];
int type[N];
void getv(int u) {
  if (type[u] == 4) return;
  for (int k = 0; k < (2); k++)
    if (ch[u][k]) getv(ch[u][k]);
  int lc = ch[u][0], rc = ch[u][1];
  if (type[u] == 0) {
    val[u] = val[lc] & val[rc];
  } else if (type[u] == 1) {
    val[u] = val[lc] | val[rc];
  } else if (type[u] == 2) {
    val[u] = val[lc] ^ val[rc];
  } else if (type[u] == 3) {
    val[u] = !val[lc];
  }
}
int dp[N];
void dfs(int u) {
  if (type[u] == 4) return;
  for (int k = 0; k < (2); k++) {
    int v = ch[u][k], o = ch[u][k ^ 1];
    if (type[u] == 0) {
      dp[v] = val[o] && dp[u];
    } else if (type[u] == 1) {
      dp[v] = !val[o] && dp[u];
    } else {
      dp[v] = dp[u];
    }
  }
  for (int k = 0; k < (2); k++)
    if (ch[u][k]) dfs(ch[u][k]);
}
string t[] = {"AND", "OR", "XOR", "NOT", "IN"};
void work() {
  int n;
  cin >> n;
  for (int u = 1; u <= (n); u++) {
    string s;
    cin >> s;
    int x, y;
    y = 0;
    if (s == t[3] || s == t[4]) {
      cin >> x;
    } else {
      cin >> x >> y;
    }
    ch[u][0] = x, ch[u][1] = y;
    for (int k = 0; k < (5); k++)
      if (s == t[k]) type[u] = k;
    if (type[u] == 4) val[u] = x, ch[u][0] = 0;
  }
  getv(1);
  dp[1] = 1;
  dfs(1);
  for (int u = 1; u <= (n); u++) {
    if (type[u] == 4) {
      cout << (val[1] ^ dp[u]);
    }
  }
  test("");
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  work();
}
