const MAXN = 100000;
var n, j, k, i, dif, p1, p2, mp: integer;
	A: array[1..2*MAXN] of integer;
	B, C: array[1..MAXN] of integer;

procedure swap(var a, b: integer);
var tmp: integer;
begin
	tmp := a;
	a := b;
	b := tmp;
end;

begin
	reset(input, 'split.in');
	rewrite(output, 'split.out');
	read(n);
	for i := 1 to 2 * n do
		read(a[i]);
	for i := 1 to n do begin
		dif := 1000000000;
		mp := 1;
		p1 := 1;
		p2 := 2;
    	for j := 1 to 2 * (n + 1 - i) do
    		for k := j + 1 to 2 * (n + 1 - i) do
    			if (abs(a[j] - a[k]) <= dif) then 
    				if (abs(a[j] - a[k]) <> dif) or (a[mp] <= a[j])
    					or (a[mp] <= a[k]) then begin
    					dif := abs(a[j] - a[k]);
    					p1 := j;
    					p2 := k;
    					mp := p1;
    					if (a[p1] < a[p2]) then mp := p2;
    				end;
   		if (a[p1] > a[p2]) then begin
   			b[i] := a[p1];
   			c[i] := a[p2];
   		end
   		else begin
   			b[i] := a[p2];
   			c[i] := a[p1];
   		end;	
   		swap(a[p2], a[2 * (n + 1 - i)]);
   		swap(a[p1], a[2 * (n + 1 - i) - 1]);
	end;
	for i := 1 to n do
		write(b[i], ' ');
    writeln;
    for i := 1 to n do
		write(c[i], ' ');
    writeln;
end.