#include <bits/stdc++.h>
namespace std {
bool __LOG_ = false;
const int MOD7 = 1000000007;
const long long MOD9 = 998244353;
const long long MODL = 1000000007;
const int INF = 1000000007;
const long long INFL = 4ll * 1000000007ll * 1000000007ll;
const long double PI = acos(-1);
const int HPRIME = 31;
const long double EPS = 1e-30;
inline void No() { cout << "NO" << endl; }
inline void Yes() { cout << "YES" << endl; }
template <typename T1, typename T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& out, const std::pair<T1, T2> p) {
  return out << p.first << " " << p.second;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for (auto& x : vec) {
    in >> x;
  }
  return in;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (auto x : vec) {
    out << x << " ";
  }
  return out;
}
template <typename T1, typename T2>
std::vector<T1>& operator+=(std::vector<T1>& a, const std::vector<T2>& b) {
  assert(a.size() == b.size());
  for (size_t i = 0; i < a.size(); ++i) {
    a[i] += b[i];
  }
  return a;
}
template <typename T1, typename T2>
std::vector<T1>& operator-=(std::vector<T1>& a, const std::vector<T2>& b) {
  assert(a.size() == b.size());
  for (size_t i = 0; i < a.size(); ++i) {
    a[i] -= b[i];
  }
  return a;
}
template <typename T1, typename T2>
std::vector<T1>& operator*=(std::vector<T1>& a, const std::vector<T2>& b) {
  assert(a.size() == b.size());
  for (size_t i = 0; i < a.size(); ++i) {
    a[i] *= b[i];
  }
  return a;
}
template <typename T1, typename T2>
std::vector<T1>& operator/=(std::vector<T1>& a, const std::vector<T2>& b) {
  assert(a.size() == b.size());
  for (size_t i = 0; i < a.size(); ++i) {
    a[i] /= b[i];
  }
  return a;
}
template <typename T>
std::vector<T> operator+(const std::vector<T>& a, const std::vector<T>& b) {
  std::vector<T> ans(a);
  ans += b;
  return ans;
}
template <typename T>
std::vector<T> operator-(const std::vector<T>& a, const std::vector<T>& b) {
  std::vector<T> ans(a);
  ans -= b;
  return ans;
}
template <typename T>
std::vector<T> operator*(const std::vector<T>& a, const std::vector<T>& b) {
  std::vector<T> ans(a);
  ans *= b;
  return ans;
}
template <typename T>
std::vector<T> operator/(const std::vector<T>& a, const std::vector<T>& b) {
  std::vector<T> ans(a);
  ans /= b;
  return ans;
}
template <typename T>
T max(std::vector<T> v) {
  T ans = v[0];
  for (auto x : v) {
    ans = std::max(ans, x);
  }
  return ans;
}
template <typename T>
T min(std::vector<T> v) {
  T ans = v[0];
  for (auto x : v) {
    ans = std::min(ans, x);
  }
  return ans;
}
template <typename T1, typename T2>
std::pair<T1, T2> operator+(const std::pair<T1, T2>& a,
                            const std::pair<T1, T2>& b) {
  return std::pair<T1, T2>(a.first + b.first, a.second + b.second);
}
template <typename T1, typename T2>
std::pair<T1, T2> operator-(const std::pair<T1, T2>& a,
                            const std::pair<T1, T2>& b) {
  return std::pair<T1, T2>(a.first - b.first, a.second - b.second);
}
template <typename T1, typename T2>
std::pair<T1, T2> operator*(const std::pair<T1, T2>& a,
                            const std::pair<T1, T2>& b) {
  return std::pair<T1, T2>(a.first * b.first, a.second * b.second);
}
template <typename T1, typename T2>
std::pair<T1, T2> operator/(const std::pair<T1, T2>& a,
                            const std::pair<T1, T2>& b) {
  return std::pair<T1, T2>(a.first / b.first, a.second / b.second);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.setf(ios::fixed);
  cout.precision(10);
}
bool prime(long long n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
long long binpow(long long a, long long b, long long mod = MOD7) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long hak(long long a, long long mod = MOD7) {
  return binpow(a, mod - 2, mod);
}
}  // namespace std
using namespace std;
const int N = 1000002;
const int logN = 24;
void precalc() {}
int n;
vector<int> g[N];
char t[N];
bool val[N];
bool m[N];
vector<int> leaf;
int dfs1(int v = 1) {
  if (t[v] == 'i') return val[v];
  if (t[v] == '!') return val[v] = !dfs1(g[v][0]);
  if (t[v] == '&') return val[v] = (dfs1(g[v][0]) & dfs1(g[v][1]));
  if (t[v] == '|') return val[v] = (dfs1(g[v][0]) | dfs1(g[v][1]));
  if (t[v] == '^') return val[v] = (dfs1(g[v][0]) ^ dfs1(g[v][1]));
}
void dfs(int v = 1) {
  if (t[v] == 'i') {
    if (__LOG_) cerr << ("v") << " = " << (v) << endl;
    m[v] = true;
    return;
  }
  if (t[v] == '!') {
    dfs(g[v][0]);
    return;
  }
  if (t[v] == '&') {
    int v0 = val[g[v][0]], v1 = val[g[v][1]];
    if (v == 5) {
      if (__LOG_) cerr << ("v0") << " = " << (v0) << endl;
      if (__LOG_) cerr << ("v1") << " = " << (v1) << endl;
    }
    if (!v0 && !v1) {
      return;
    }
    if (v0 && v1) {
      dfs(g[v][0]);
      dfs(g[v][1]);
      return;
    }
    if (v0 && !v1) {
      dfs(g[v][1]);
      return;
    }
    if (v1 && !v0) {
      dfs(g[v][0]);
      return;
    }
  }
  if (t[v] == '|') {
    int v0 = val[g[v][0]], v1 = val[g[v][1]];
    if (v0 && v1) {
      return;
    }
    if (!v0 && !v1) {
      dfs(g[v][0]);
      dfs(g[v][1]);
      return;
    }
    if (v0) {
      dfs(g[v][0]);
      return;
    }
    if (v1) {
      dfs(g[v][1]);
      return;
    }
  }
  if (t[v] == '^') {
    dfs(g[v][0]);
    dfs(g[v][1]);
  }
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (s == "IN") {
      int x;
      cin >> x;
      val[i] = x;
      t[i] = 'i';
    } else if (s == "NOT") {
      int x;
      cin >> x;
      g[i].push_back(x);
      t[i] = '!';
    } else if (s == "AND") {
      int x, y;
      cin >> x >> y;
      g[i].push_back(x);
      g[i].push_back(y);
      t[i] = '&';
    } else if (s == "OR") {
      int x, y;
      cin >> x >> y;
      g[i].push_back(x);
      g[i].push_back(y);
      t[i] = '|';
    } else if (s == "XOR") {
      int x, y;
      cin >> x >> y;
      g[i].push_back(x);
      g[i].push_back(y);
      t[i] = '^';
    }
  }
  int x = dfs1();
  dfs();
  if (__LOG_) cerr << ("m[3]") << " = " << (m[3]) << endl;
  for (int i = 1; i <= n; i++) {
    if (t[i] == 'i') {
      cout << (x ^ m[i]);
    }
  }
  cout << endl;
}
int main() {
  __LOG_ = false;
  cout.setf(ios::fixed);
  cout.precision(20);
  fastIO();
  precalc();
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
