#include <bits/stdc++.h>
#define ll long long
#define MAX 1000001
using namespace std;
vector < pair<int,int> > v;
int level[MAX],ht;
string s[MAX];
int assign(int i,int h){
ht = max(ht,h);
if (v[i].first<0) level[h] = max(level[i],-v[i].first);
else assign(v[i].first-1,h+1);
if (v[i].second<0) level[h] = max(level[h],-v[i].second);
else assign(v[i].second-1,h+1);
return 0;
}
int main(){
int n;
cin >> n;
v.resize(n+1);
for (int i=0;i<n;i++){
scanf("%d%d",&v[i].first,&v[i].second);
}
assign(0,0);
for (int i=0;i<MAX;i++){
int temp = level[i],c = 0;
while(temp){
s[i]+=(temp%2)+'0';
temp/=2;
c++;
}
for (int j=0;j<c/2;j++) swap(s[i][j],s[i][c-j-1]);
}
double mx = level[ht];
int v = ht;
double pw = 1;
for (int i=ht;i>=0;i--){
if (pw>mx) break;
if (level[i]/pw>mx){
mx = level[i]/pw;
v = i;
}
pw*=2;
}
cout << s[v];
for (int i=0;i<=v;i++) cout << 0;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgTUFYIDEwMDAwMDEKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvciA8IHBhaXI8aW50LGludD4gPiB2OwppbnQgbGV2ZWxbTUFYXSxodDsKCnN0cmluZyBzW01BWF07CgppbnQgYXNzaWduKGludCBpLGludCBoKXsKCWh0ID0gbWF4KGh0LGgpOwoJaWYgKHZbaV0uZmlyc3Q8MCkgbGV2ZWxbaF0gPSBtYXgobGV2ZWxbaV0sLXZbaV0uZmlyc3QpOwoJZWxzZSBhc3NpZ24odltpXS5maXJzdC0xLGgrMSk7CglpZiAodltpXS5zZWNvbmQ8MCkgbGV2ZWxbaF0gPSBtYXgobGV2ZWxbaF0sLXZbaV0uc2Vjb25kKTsKCWVsc2UgYXNzaWduKHZbaV0uc2Vjb25kLTEsaCsxKTsJCglyZXR1cm4gMDsKfQoKaW50IG1haW4oKXsKCWludC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