#include<iostream> #include<memory.h> using namespace std; int K,N,M; int pre[1010],in[1010],post[1010],map[1010]; bool canRebuild; void reBuild(int low,int up){ if(up>=low){ int m=map[K++]; if( m==-1 || m<low || m>up){ canRebuild=false; return; } reBuild(low,m-1); reBuild(m+1,up); post[M++]=in[m]; } } int main(){ while(cin>>N){ for(int i=0;i<N;++i) cin>>pre[i]; for(int j=0;j<N;++j) cin>>in[j]; memset(map,-1,sizeof(map)); for(int i=0;i<N;++i) for(int j=0;j<N;++j) if(pre[i]==in[j]) map[i]=j; M=K=0; canRebuild=true; reBuild(0,N-1); if(canRebuild){ for(int i=0;i<N;++i) cout<<post[i]<<" "; }else cout<<"No"; cout<<endl; } }