program hotrotinhoc;
var a,b: array[1..8000] of integer;
c,d1: array[1..8000] of ansistring;
j,i,d,d2,n: integer;
t,t1,tg,tg1,st,s: ansistring;
begin
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
write('b[',i,']='); readln(b[i]);
end;
for i:=1 to n do if a[i] mod 2 =0 then
begin
str(a[i],t);
s:=s+t;
end
else
begin
str(a[i],t1);
st:=st+t1;
end;
for i:=1 to n do if b[i] mod 2=0 then
begin
str(b[i],t);
s:=s+t;
end
else
begin
str(b[i],t1);
st:=st+t1;
end;
d:=0;
for i:=1 to length(s) do
begin
inc(d);
c[d]:=s[i];
end;
for i:=1 to d do for j:=i to d do
if c[i]>c[j] then
begin
tg:=c[i];
c[i]:=c[j];
c[j]:=tg;
end;
for i:=1 to d do write(c[i],' ');
d2:=0;
for i:=1 to length(st) do
begin
inc(d2);
d1[d2]:=st[i];
end;
for i:=1 to d2 do
for j:=i to d2 do
if d1[i]<d1[j] then
begin
tg1:=d1[i];
d1[i]:=d1[j];
d1[j]:=tg1;
end;
for i:=1 to d2 do write(d1[i],' ');
readln
end.