#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int N;
struct node {
  int id;
  bool H;
  string S;
  vector<int> *F, *T;
  node *L, *R;
} data[MAXN];
bool P[MAXN];
void input(node *now) {
  cin >> now->S;
  if (now->S == "IN") {
    cin >> now->H;
    now->L = NULL;
    now->R = NULL;
  } else if (now->S == "NOT") {
    int X;
    cin >> X;
    now->L = &data[X];
    now->R = NULL;
  } else {
    int X, Y;
    cin >> X >> Y;
    now->L = &data[X];
    now->R = &data[Y];
  }
  now->T = NULL;
  now->F = NULL;
  return;
}
vector<int> *merge(vector<int> *X, vector<int> *Y) {
  if (X == NULL) {
    return Y;
  }
  if (Y == NULL) {
    return X;
  }
  if (Y->size() > X->size()) {
    swap(X, Y);
  }
  for (int it : *Y) {
    X->push_back(it);
  }
  return X;
}
void ans(node *now) {
  node *lef, *rig;
  lef = now->L;
  rig = now->R;
  if (now->S == "IN") {
    if (now->H) {
      now->F = new vector<int>;
      now->F->clear();
      now->F->push_back(now->id);
    } else {
      now->T = new vector<int>;
      now->T->clear();
      now->T->push_back(now->id);
    }
    return;
  }
  if (now->S == "NOT") {
    ans(lef);
    now->H = !lef->H;
    now->T = lef->F;
    now->F = lef->T;
    return;
  }
  ans(lef);
  ans(rig);
  if (now->S == "AND") {
    now->H = lef->H & rig->H;
    if (rig->H) {
      now->T = merge(now->T, lef->T);
    } else {
      now->F = merge(now->F, lef->T);
    }
    if (lef->H) {
      now->T = merge(now->T, rig->T);
    } else {
      now->F = merge(now->F, rig->T);
    }
    now->F = merge(now->F, lef->F);
    now->F = merge(now->F, rig->F);
    return;
  }
  if (now->S == "OR") {
    now->H = lef->H | rig->H;
    if (rig->H) {
      now->T = merge(now->T, lef->F);
    } else {
      now->F = merge(now->F, lef->F);
    }
    if (lef->H) {
      now->T = merge(now->T, rig->F);
    } else {
      now->F = merge(now->F, rig->F);
    }
    now->T = merge(now->T, lef->T);
    now->T = merge(now->T, rig->T);
    return;
  }
  now->H = lef->H ^ rig->H;
  if (rig->H) {
    now->T = merge(now->T, lef->F);
    now->F = merge(now->F, lef->T);
  } else {
    now->F = merge(now->F, lef->F);
    now->T = merge(now->T, lef->T);
  }
  if (lef->H) {
    now->T = merge(now->T, rig->F);
    now->F = merge(now->F, rig->T);
  } else {
    now->F = merge(now->F, rig->F);
    now->T = merge(now->T, rig->T);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    input(&data[i]);
    data[i].id = i;
  }
  ans(&data[1]);
  if (data[1].T != NULL) {
    for (int it : *data[1].T) {
      P[it] = 1;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (data[i].S == "IN") {
      cout << P[i];
    }
  }
  cout << '\n';
  return 0;
}
