#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int one[1000000];
void quickSort(int le, int ri){
int key = one[le];
int a=le, b=ri;
while(a < b){
while(one[b] >= key && a < b){
b--;
}
one[a] = one[b];
while(one[a] <= key && a < b){
a++;
}
one[b] = one[a];
}
one[a] = key;
if(le < a-1){
quickSort(le, a-1);
}
if(ri > a+1){
quickSort(a+1, ri);
}
}
int main(){
int n;
while(cin >> n){
for(int e=1; e <= n; e++){
one[e] = rand()%10;
}
for(int e=1; e <= n; e++){
printf("%d%c", one[e], e==n ? '\n':' ');
}
quickSort(1,n);
for(int e=1; e <= n; e++){
printf("%d%c", one[e], e==n ? '\n':' ');
}
}
return 0;
}