#include <bits/stdc++.h>
using namespace std;
template <class T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <typename Args>
void kill(Args args) {
  cout << args << "\n";
  exit(0);
}
const double PI = acos(-1);
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1010100;
string types[N];
int input_nums = 0;
set<int> input_idx;
int vals[N];
int other[N];
vector<int> adj[N];
int will_change[N];
int n;
int process(vector<int> temp, string type) {
  if (type == "AND") {
    return temp[0] & temp[1];
  } else if (type == "OR") {
    return temp[0] | temp[1];
  } else if (type == "XOR") {
    return temp[0] ^ temp[1];
  } else if (type == "NOT") {
    return !temp[0];
  } else
    return temp[0];
}
bool check(int tocheck, int p) {
  if (types[p] == "NOT") {
    return 1;
  }
  if (types[p] == "AND") {
    return ((1 ^ vals[tocheck]) & (vals[other[tocheck]])) != vals[p];
  }
  if (types[p] == "XOR") {
    return ((1 ^ vals[tocheck]) ^ (vals[other[tocheck]])) != vals[p];
  }
  if (types[p] == "OR") {
    return ((1 ^ vals[tocheck]) | (vals[other[tocheck]])) != vals[p];
  } else
    return 1;
}
int dfs1(int v, int p = 0) {
  if (types[v] == "IN") return vals[v];
  vector<int> temp;
  for (int next : adj[v]) {
    if (next != p) temp.emplace_back(dfs1(next, v));
  }
  return vals[v] = process(temp, types[v]);
}
void dfs2(int v, int p = 0, bool cur = 1) {
  if (types[v] == "IN") {
    will_change[v] = cur;
    return;
  }
  for (int next : adj[v]) {
    if (next != p) {
      dfs2(next, v, cur & (check(next, v)));
    }
  }
}
void solve(int testnum) {
  cin >> n;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    types[i] = s;
    if (s == "AND" || s == "OR" || s == "XOR") {
      int x, y;
      cin >> x >> y;
      adj[i].emplace_back(x);
      adj[x].emplace_back(i);
      adj[i].emplace_back(y);
      adj[y].emplace_back(i);
      other[x] = y;
      other[y] = x;
    } else if (s == "NOT") {
      int x;
      cin >> x;
      adj[i].emplace_back(x);
      adj[x].emplace_back(i);
      other[x] = x;
    } else {
      input_nums++;
      int x;
      cin >> x;
      input_idx.insert(i);
      vals[i] = x;
      other[x] = x;
    }
  }
  dfs1(1);
  dfs2(1);
  for (int i : input_idx) {
    if (will_change[i]) {
      cout << (1 ^ vals[1]);
    } else
      cout << vals[1];
  }
}
void precompute() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  int testcase = 1;
  clock_t zzzx = clock();
  precompute();
  for (int i = 1; i <= testcase; i++) {
    solve(i);
  }
  double elapsed_time = (double)(clock() - zzzx) / CLOCKS_PER_SEC;
  cerr << "elapsed_time"
       << " = " << (elapsed_time) << "\n";
  return 0;
}
