#include<bits/stdc++.h>
using namespace std;
int ii;
void showlist(int a[],int len){
for(int i=0;i<len;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
int getindex(int a[],int left,int right){
int t=a[left];
while(left!=right){
while(a[right]>t&&left<right){
right--;
}
a[left]=a[right];
showlist(a,ii);
while(a[left]<t&&left<right){
left++;
}
a[right]=a[left];
showlist(a,ii);
}
a[left]=t;
showlist(a,ii);
return left;
}
void quicksort(int a[],int left,int right){
if(left<right){
int index = getindex(a,left,right);
quicksort(a,0,index-1);
quicksort(a,index+1,right);
}
}
int main(int argc, char** argv) {
int x;
freopen("in.txt","r",stdin);
int a[10];
while(cin>>x){
a[ii]=x;
ii++;
}
showlist(a,ii);
int left=0,right=ii-1;
quicksort(a,left,right);
cout<<"dddddd"<<endl;
showlist(a,ii);
return 0;
}