#include <bits/stdc++.h>
const int N = 26, M = 50006;
int n, a[3][N], b[2 * N], f[N][M * N];
bool chosen[2 * N];
int main() {
  std::cin >> n;
  for (int i = 1; i <= 2 * n; ++i) {
    std::cin >> b[i];
  }
  std::sort(b + 1, b + 2 * n + 1);
  a[1][1] = b[1], a[2][n] = b[2];
  int sum = 0;
  f[0][0] = 19260817;
  for (int i = 3; i <= 2 * n; ++i) {
    sum += b[i];
    for (int k = n - 1; k; --k) {
      for (int j = sum; j >= b[i]; --j) {
        if (!f[k][j] && f[k - 1][j - b[i]]) {
          f[k][j] = i;
        }
      }
    }
  }
  for (int i = sum / 2; ~i; --i) {
    if (f[n - 1][i]) {
      for (int k = n; k != 1; i -= b[f[--k][i]]) {
        a[1][k] = b[f[k - 1][i]];
        chosen[f[k - 1][i]] = true;
      }
    }
  }
  for (int i = 3, j = n - 1; i <= 2 * n; ++i) {
    if (!chosen[i]) {
      a[2][j--] = b[i];
    }
  }
  for (int i = 1; i <= 2; ++i)
    for (int j = 1; j <= n; ++j) printf("%d%c", a[i][j], " \n"[j == n]);
  return 0;
}
