#include<bits/stdc++.h>
using namespace std;
pair <int,int> a[1000000];
int arr1[1000000],arr2[100000];
int main()
{
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&arr1[i]); //First row
for(i=0;i<n;i++) scanf("%d",&arr2[i]); //Second row
for(i=0;i<n;i++)
{
a[i]=make_pair(arr1[i],arr2[i]);
}
sort(a,a+n); //Sorts according to first row
printf("\n");
for(i=0;i<n;i++) printf("%d ",a[i].first);
printf("\n");
for(i=0;i<n;i++) printf("%d ",a[i].second);
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKcGFpciA8aW50LGludD4gYVsxMDAwMDAwXTsKaW50IGFycjFbMTAwMDAwMF0sYXJyMlsxMDAwMDBdOwppbnQgbWFpbigpCnsKICAgIGludCBuLGk7CiAgICBzY2FuZigiJWQiLCZuKTsKICAgIGZvcihpPTA7aTxuO2krKykgc2NhbmYoIiVkIiwmYXJyMVtpXSk7IC8vRmlyc3Qgcm93CiAgICBmb3IoaT0wO2k8bjtpKyspIHNjYW5mKCIlZCIsJmFycjJbaV0pOyAvL1NlY29uZCByb3cKICAgIGZvcihpPTA7aTxuO2krKykKICAgIHsKICAgICAgICBhW2ldPW1ha2VfcGFpcihhcnIxW2ldLGFycjJbaV0pOwogICAgfQogICAgc29ydChhLGErbik7IC8vU29ydHMgYWNjb3JkaW5nIHRvIGZpcnN0IHJvdwogICAgcHJpbnRmKCJcbiIpOwogICAgZm9yKGk9MDtpPG47aSsrKSBwcmludGYoIiVkICIsYVtpXS5maXJzdCk7CiAgICBwcmludGYoIlxuIik7CiAgICBmb3IoaT0wO2k8bjtpKyspIHByaW50ZigiJWQgIixhW2ldLnNlY29uZCk7CiAgICByZXR1cm4gMDsKfQo=