import java.io.*;
import java.util.*;

public class split_va {
	public static void main(String[] args) {
		new split_va().run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public class Diff implements Comparable<Diff> {
		int diff;
		int l, r;

		public Diff(int diff, int l, int r) {
			this.diff = diff;
			this.l = l;
			this.r = r;
		}

		public int compareTo(Diff d) {
			return d.diff == diff ? d.l - l : diff - d.diff;
		}
	}

	public void solve() throws IOException {
		int n = nextInt();

		int[] l = new int[2 * n];
		int[] r = new int[2 * n];

		int[] a = new int[2 * n];
		for (int i = 0; i < a.length; i++) {
			a[i] = nextInt();
			l[i] = i - 1;
			r[i] = i + 1;
		}
		Arrays.sort(a);

		TreeSet<Diff> ts = new TreeSet<Diff>();

		for (int i = 0; i < a.length - 1; i++) {
			ts.add(new Diff(a[i + 1] - a[i], i, i + 1));
		}

		ArrayList<Integer> ans1 = new ArrayList<Integer>();
		ArrayList<Integer> ans2 = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {
			Diff z = ts.pollFirst();
			ans1.add(a[z.l]);
			ans2.add(a[z.r]);

			if (l[z.l] != -1) {
				ts.remove(new Diff(a[z.l] - a[l[z.l]], l[z.l], z.l));
			}
			if (r[z.r] != 2 * n) {
				ts.remove(new Diff(a[r[z.r]] - a[z.r], z.r, r[z.r]));
			}

			if (l[z.l] != -1)
				r[l[z.l]] = r[z.r];
			if (r[z.r] != 2 * n)
				l[r[z.r]] = l[z.l];

			if (l[z.l] != -1 && r[z.r] != 2 * n)
				ts.add(new Diff(a[r[z.r]] - a[l[z.l]], l[z.l], r[z.r]));
		}

		for (int z : ans2) {
			out.print(z + " ");
		}
		out.println();
		for (int z : ans1) {
			out.print(z + " ");
		}
		out.println();
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("split.in"));
			out = new PrintWriter("split.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
