//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 1000005
#define oo 2000000007
const double PI = acos(-1.0);
double fRand(double fMin, double fMax)
{
double f = (double)rand() / RAND_MAX;
return fMin + f * (fMax - fMin);
}
template <class T>
T min(T a, T b, T c) {
return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
return max(a, max(b, c));
}
int readInt () {
bool minus = false;
int result = 0;
char ch;
ch = getchar();
while (true) {
if (ch == '-') break;
if (ch >= '0' && ch <= '9') break;
ch = getchar();
}
if (ch == '-') minus = true; else result = ch-'0';
while (true) {
ch = getchar();
if (ch < '0' || ch > '9') break;
result = result*10 + (ch - '0');
}
if (minus)
return -result;
else
return result;
}
bool cmp(string &s, string &t) {
if (s.length() < t.length()) return true;
if (s.length() > t.length()) return false;
return (s < t);
}
string toBin(int n) {
string s;
if (n == 0) s += "0";
while (n > 0) {
s += n%2 + '0';
n /= 2;
}
reverse(s.begin(), s.end());
return s;
}
int n, k;
vector<int> ke[maxN];
string *d[3*maxN];
void Calc(int u) {
if (u <= n) {
fto(i, 0, 1) Calc(ke[u][i]);
if (cmp(*d[ke[u][0]], *d[ke[u][1]])) d[u] = d[ke[u][1]];
else d[u] = d[ke[u][0]];
*d[u] += '0';
}
}
int main () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
n = readInt(); k = n;
fto(i, 1, n) {
d[i] = new string();
fto(j, 1, 2) {
int x = readInt();
if (x > 0) ke[i].pb(x);
else {
d[++k] = new string();
*d[k] = toBin(-x);
ke[i].pb(k);
}
}
}
Calc(1);
string ans = *d[1];
fto(i, 0, ans.length()-1) putchar(ans[i]);
return 0;
}
Ly84NDEwNDk3MTEwMTA0ODQxMTQ5NyAtIENhbiB5b3UgZ3Vlc3Mgd2hhdCBkb2VzIHRoaXMgbWVhbj8KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgY29tcGxleDxkb3VibGU+IHBvaW50OwojZGVmaW5lIG1hcGlpIG1hcDxpbnQsIGludD4KI2RlZmluZSBkZWJ1ZyhhKSBjb3V0IDw8ICNhIDw8ICI6ICIgPDwgYSA8PCBlbmRsCiNkZWZpbmUgZGVidWdhMShhLCBsLCByKSBmdG8oaSwgbCwgcikgY291dCA8PCBhW2ldIDw8ICIgIjsgY291dCA8PCBlbmRsCiNkZWZpbmUgZmR0byhpLCAgciwgbCkgZm9yKGludCBpID0gKHIpOyBpID49IChsKTsgLS1pKQojZGVmaW5lIGZ0byhpLCBsLCByKSBmb3IoaW50IGkgPSAobCk7IGkgPD0gKHIpOyArK2kpCiNkZWZpbmUgZm9yaXQoaXQsIHZhcikgZm9yKF9fdHlwZW9mKHZhci5iZWdpbigpKSBpdCA9IHZhci5iZWdpbigpOyBpdCAhPSB2YXIuZW5kKCk7IGl0KyspCiNkZWZpbmUgZm9ycml0KHJpdCwgdmFyKSBmb3IoX190eXBlb2YodmFyLnJiZWdpbigpKSByaXQgPSB2YXIucmJlZ2luKCk7IHJpdCAhPSB2YXIucmVuZCgpOyByaXQrKykKI2RlZmluZSBpaSBwYWlyPGludCwgaW50PgojZGVmaW5lIGlpaSBwYWlyPGludCwgaWk+CiNkZWZpbm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3RyaW5nKCk7CiAgICAgICAgZnRvKGosIDEsIDIpIHsKICAgICAgICAgICAgaW50IHggPSByZWFkSW50KCk7CiAgICAgICAgICAgIGlmICh4ID4gMCkga2VbaV0ucGIoeCk7CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgZFsrK2tdID0gbmV3IHN0cmluZygpOwogICAgICAgICAgICAgICAgKmRba10gPSB0b0JpbigteCk7CiAgICAgICAgICAgICAgICBrZVtpXS5wYihrKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBDYWxjKDEpOwoKICAgIHN0cmluZyBhbnMgPSAqZFsxXTsKICAgIGZ0byhpLCAwLCBhbnMubGVuZ3RoKCktMSkgcHV0Y2hhcihhbnNbaV0pOwoKICAgIHJldHVybiAwOwp9Cg==