#include<iostream>
using namespace std;
class SortedArray{
private:
int len;
int* p;
public:
SortedArray(int _len){
len=_len;
p=new int[len];
}
~SortedArray();
void sortit();
SortedArray operator+(const SortedArray&);
int& operator[](int);
friend ostream& operator<<(ostream& out,SortedArray&);
friend istream& operator>>(istream& in,SortedArray&);
int getlen(){
return len; }
};
ostream& operator<<(ostream& out,SortedArray& sa){
for (int i = 0; i < sa.len; i++)
{
out<<*(sa.p+i)<<" ";
}
return out;
}
istream& operator>>(istream& in,SortedArray& sa){
in >>sa.len;
if(sa.p){
delete []sa.p;
}
if (sa.len>0)
{
sa.p=new int[sa.len];
}
else{
sa.p=NULL;
}
for (int i = 0; i < sa.len; i++)
{
in >>sa.p[i];
}
return in;
}
int& SortedArray::operator[](int i){
return p[i];
}
SortedArray::~SortedArray(){}
void SortedArray::sortit(){
for(int i=0;i<len-1;i++){
for(int j=0;j<len-1-i;j++){
if(*(p+j)>*(p+j+1)){
int a=*(p+j);*(p+j)=*(p+j+1);*(p+j+1)=a;
}
}
}
}
SortedArray SortedArray::operator+(const SortedArray& a){
SortedArray t(1);
t.len=len+a.len;
if (t.len>0)
{
t.p=new int[t.len];
}
else{
t.p=NULL;
}
for (int i=0; i<len; i++)
{
*(t.p+i)=*(p+i);
}
for (int i= 0; i< a.len; i++)
{
*(t.p+i+len)=*(a.p+i);
}
return t;
}
int main(){
SortedArray sa1(3);
cin>>sa1;
SortedArray sa2(3);
cin>>sa2;
sa1.sortit();
sa2.sortit();
cout<<sa1<<endl;
cout<<sa2<<endl;
SortedArray sa3=sa1+sa2;
sa3.sortit();
cout<<sa3<<endl;
if (sa1.getlen()>1)
{
sa1[1]=10;
}
sa1.sortit();
cout<<sa1<<endl;
if (sa2.getlen()>3)
{
cout<<sa2[3]<<endl;
}
else{
cout<<"non"<<endl;