#include using namespace std; #define ll long long #define rep(i,n) for(ll i=0; i<(ll)(n); i++) #define repi(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++) using vi=vector; using vvi=vector; using vll=vector; using vvll=vector; template bool chmin(T&a,const S& b){ return a>b?a=b,1:0; } template bool chmax(T&a,const S& b){ return a; using vp=vector

; using vvp=vector; struct UnionFind { vector par,siz; UnionFind(int n) : par(n,-1),siz(n,1) {} int root(int x){ if(par[x]==-1)return x; else return par[x]=root(par[x]); } bool issame(int x,int y){ return root(x)==root(y); } bool unite(int x,int y){ x=root(x),y=root(y); if(x==y)return false; if(siz[x]=mod)x-=mod; return *this; } mint& operator-=(mint r){ if((x-=r.x)<0)x+=mod; return *this; } mint& operator*=(mint r){ x=1LL*x*r.x%mod; return *this; } mint& operator/=(mint r){ return *this*=r.inv(); } friend mint operator+(mint a,mint b){ return a+=b; } friend mint operator-(mint a,mint b){ return a-=b; } friend mint operator*(mint a,mint b){ return a*=b; } friend mint operator/(mint a,mint b){ return a/=b; } mint inv() const{return pow(mod-2);} mint pow(ll b) const{ mint a=*this,c=1; while(b){ if(b&1)c*=a; a*=a; b>>=1; } return c; } }; using vm=vector; template struct SegmentTree{ private: int _n,size,log; vector dat; void update(int k){ dat[k]=op(dat[2*k],dat[2*k+1]); } public: SegmentTree():SegmentTree(0){} SegmentTree(int n):SegmentTree(vector(n,e())){} SegmentTree(const vector& v) : _n(int(v.size())){ log=0; while((1<(2*size,e()); for(int i=0; i<_n; i++)dat[size+i]=v[i]; for(int i=size-1; i>=1; i--){ update(i); } } void set(int p,S x){ p+=size; dat[p]=x; for(int i=1; i<=log; i++)update(p>>i); } S get(int p) const {return dat[p+size];} S prod(int l,int r) const{ S sml=e(),smr=e(); l+=size; r+=size; while(l>=1; r>>=1; } } S all_prod() const {return dat[1];} }; void solve(int test){ int n; cin >> n; vi a(n),b(n); rep(i,n)cin >> a[i],a[i]--; rep(i,n)cin >> b[i],b[i]--; vi invb(n); rep(i,n)invb[b[i]]=i; rep(i,n)cout <=0){ int u=a[inva[v]-1]; if(!seen[u] && invb[u]>invb[v]){ int x=inva[u]; int y=inva[v]; swap(a[x],a[y]); seen[u]=1; seen[v]=1; inva[a[x]]=x; inva[a[y]]=y; } } } rep(i,n)cout << a[i]+1 << " "; cout << endl; } rep(i,n)cout << b[i]+1 << " "; cout << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int t=1; //cin >> t; rep(test,t)solve(test); }