#include <bits/stdc++.h>
#pragma comment(linker, "/stack:227420978")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double PI = 3.141592653589793116, EPS = 1e-9,
                  GOLD = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
vector<long long> HashMod(keymod, keymod + sizeof(keymod) / sizeof(long long));
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
long long n, x, y;
vector<string> label;
vector<long long> p;
vector<long long> A;
vector<vector<long long> > adj;
void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
void Input() {
  cin >> n;
  p.resize(n, -1);
  A.resize(n, 0);
  label.resize(n);
  adj.resize(n);
}
void Solve() {
  for (long long i = 0; i < n; i++) {
    cin >> label[i];
    if (label[i] == "IN") {
      cin >> A[i];
      continue;
    }
    if (label[i] == "AND" || label[i] == "OR" || label[i] == "XOR") {
      cin >> x >> y;
      x--;
      y--;
      if (label[i] == "AND") A[i] = 1;
      adj[i].push_back(x);
      adj[i].push_back(y);
      p[x] = i;
      p[y] = i;
      continue;
    }
    if (label[i] == "NOT") {
      cin >> x;
      x--;
      adj[i].push_back(x);
      p[x] = i;
      continue;
    }
  }
  queue<long long> Q;
  stack<long long> S;
  Q.push(0);
  while (!Q.empty()) {
    long long z = Q.front();
    Q.pop();
    S.push(z);
    for (auto t : adj[z]) Q.push(t);
  }
  vector<vector<long long> > changed(n);
  while (!S.empty()) {
    long long z = S.top();
    S.pop();
    if (p[z] != -1) {
      if (label[p[z]] == "AND") {
        A[p[z]] = (A[p[z]] & A[z]);
      } else if (label[p[z]] == "OR") {
        A[p[z]] = (A[p[z]] | A[z]);
      } else if (label[p[z]] == "XOR") {
        A[p[z]] = (A[p[z]] ^ A[z]);
      } else if (label[p[z]] == "NOT") {
        A[p[z]] = 1 - A[z];
      }
    }
    if (adj[z].empty()) continue;
    if (label[z] == "AND") {
      if (A[z] == 1) {
        changed[z].push_back(adj[z][0]);
        changed[z].push_back(adj[z][1]);
      } else if (A[z] == 0 && (A[adj[z][0]] || A[adj[z][1]])) {
        if (!A[adj[z][0]]) changed[z].push_back(adj[z][0]);
        if (!A[adj[z][1]]) changed[z].push_back(adj[z][1]);
      }
    } else if (label[z] == "OR") {
      if (A[z] == 1 && (!A[adj[z][0]] || !A[adj[z][1]])) {
        if (A[adj[z][0]]) changed[z].push_back(adj[z][0]);
        if (A[adj[z][1]]) changed[z].push_back(adj[z][1]);
      }
      if (A[z] == 0) {
        changed[z].push_back(adj[z][0]);
        changed[z].push_back(adj[z][1]);
      }
    } else if (label[z] == "XOR") {
      changed[z].push_back(adj[z][0]);
      changed[z].push_back(adj[z][1]);
    } else if (label[z] == "NOT")
      changed[z].push_back(adj[z][0]);
  }
  queue<long long> QQ;
  QQ.push(0LL);
  vector<bool> chosen(n, false);
  chosen[0] = true;
  while (!QQ.empty()) {
    long long z = QQ.front();
    QQ.pop();
    for (auto t : changed[z]) {
      QQ.push(t);
      chosen[t] = true;
    }
  }
  for (long long i = 1; i < n; i++) {
    if (chosen[i] && label[i] == "IN")
      cout << (1 - A[0]);
    else if (label[i] == "IN")
      cout << A[0];
  }
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ControlIO(argc, argv);
  Input();
  TimerStart();
  Solve();
  TimerStop();
  return 0;
}
void ControlIO(int argc, char* argv[]) {}
void TimerStart() {}
void TimerStop() {}
void Exit() {
  TimerStop();
  exit(0);
}
